Calls an action.

@param string $handler
@param array $arguments
@throws EndocoreException
@return Response
517858
public function callAction(string $handler, array $arguments = []): Response
    {
        if (!class_exists($handler)) {
            throw new EndocoreException('Action class not found.');
        }

        /** @var \Bloatless\Endocore\Action\ActionInterface $action */
        $action = new $handler($this->config, $this->logger, $this->request);
        return $action->__invoke($arguments);
    }
140087
protected function dispatchEventToEventHandler($event, $arguments)
    {
        if ($this->eventHandler == null || ! method_exists($this->eventHandler, $method = "on{$event}")) {
            return;
        }

        try {
            $this->eventHandler->$method(...$arguments);
        } catch (Exception $e) {
            $this->handleException($e);
        } catch (Throwable $e) {
            $this->handleException(new FatalThrowableError($e));
        }
    }
1051601
public function listen($event, $handler)
    {
        if(array_key_exists($event, $this->broadcast)) {

            $eventObject = $this->getEventObject($event, $this->broadcast[$event]);

            if(is_callable($handler)) {
                call_user_func_array($handler, [$eventObject]);
            } else {
                call_user_func_array([$this->app->make($handler), 'listen'], [$eventObject]);
            }
        }
    }
739986
public function handle($handler = null, array $params = null): ResponseInterface
    {
        $handler = $this->handler($handler);
        $params = $this->params($params);

        $parameters = null;
        if (!$handler instanceof \Closure) {
            [$class, $method] = $this->convert($handler);

            if ($method === null) {
                $key = $handler = $class;
            } else {
                $controller = new $class;
                $handler = [$controller, $method];
                $key = "{$class}::{$method}";
            }

            $parameters = self::optimizeGet($key);
            if ($parameters === false) {
                $parameters = Builder::getCallableParameters($handler, true);
                self::optimizeSet($key, $parameters);
            }
        }

        $result = $this->container->call($handler, $params, $parameters);

        if ($result instanceof ResponseInterface) {
            return $result;
        }

        /** @var Response $response */
        $response = $this->get('response');

        return $response->default($result);
    }
268987
public function execute($command, array $arguments = array(), $cwd = null)
    {
        $arguments += $this->getGlobalArguments();

        try {
            $result = $this->adapter->execute($command, $arguments, $cwd);
        } catch (\Exception $e) {
            // @todo move to a generic error handler? Something similar to the ParserInterface
            if (preg_match('/url \'[^\']+\' non-existent/i', $e->getMessage()) ||
                preg_match('/file not found/i', $e->getMessage()) ||
                preg_match('/path not found/i', $e->getMessage())
            ) {
                throw new NotFoundException($e->getMessage());
            }

            throw $e;
        }

        return $result;
    }
361629
public function fire(string $event, array $arguments = null) {
        return $this->getEventManager()->fire($event, $arguments);
    }
1026245
public function callHandler(array $command, $method, $args = array())
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $command['command_id'], $method, $args);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
574676
protected function callHandler($handler_id, $method, array $arguments)
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $handler_id, $method, $arguments);
        } catch (Exception $ex) {
            return $ex->getMessage();
        }
    }
700288
public function callHandler($handler_id, $method, array $args)
    {
        try {
            $handlers = $this->getHandlers();
            return Handler::call($handlers, $handler_id, $method, $args);
        } catch (Exception $ex) {
            return null;
        }
    }
719066
protected function _callListener($listener, array $arguments)
    {
        try {
            call_user_func_array($listener, $arguments);
        } catch (ExceptionStop $e) {
            return $e->getMessage();
        }

        return false;
    }
55475
public function fireReturn(string $event, array $arguments = null) {
        return $this->getEventManager()->fireReturn($event, $arguments);
    }
345532
public function configure($items, $handler)
    {
        if (!is_callable($handler)) {
            throw new \InvalidArgumentException(__METHOD__ . ' Handler should be callable.');
        }

        if (!$items instanceof \Traversable && !is_array($items)) {
            throw new \InvalidArgumentException(__METHOD__ . ' items should be array or iterator.');
        }

        foreach ($items as $key => $item) {
            call_user_func($handler, $this, $key, $item);
        }

        return $this;
    }
1120504
protected function executeHandler($handler, array $parameters)
	{
		if($handler instanceof Closure)
		{
			return $this->executeClosureHandler($handler, $parameters);
		}

		$handler = $this->resolveHandler($handler);

		return $this->executeClassHandler($handler, $parameters);
	}
1141147
public function handle(array $args)
  {
    switch ( strtoupper(request()->getMethod()) ) {
      case "GET"    : return $this->handleGET($args); break;
      case "POST"   : return $this->handlePOST($args); break;
      case "PUT"    : return $this->handlePUT($args); break;
      case "PATCH"  : return $this->handlePATCH($args); break;
      case "DELETE" : return $this->handleDELETE($args); break;
      case "HEAD"   : return $this->handleHEAD($args); break;
      case "OPTIONS": return $this->handleOPTIONS($args); break;
      default       : return $this->handleCUSTOM($args); break;
    }
  }
1371919
public function handle(array $arguments)
    {
        $this->parseArguments($arguments);

        $actionClass = $this->getActionClass();
        if (class_exists($actionClass, true)) {
            try {
                /** @var \Teleport\Action\Action $handler */
                $handler = new $actionClass($this);
                $this->beforeHandle($handler);
                $handler->process();
                $this->afterHandle($handler);
            } catch (\Exception $e) {
                throw new RequestException($this, "Error handling {$this->action} Teleport request: " . $e->getMessage(), $e);
            }
        } else {
            throw new RequestException($this, "Unknown action {$this->action} specified in Teleport request.");
        }
    }
1129831
public function setHandler($handler)
    {
        if (Assert::array($handler)) {
            $this->handler = function (Event $event) use ($handler) {
                return call_user_func_array($handler, [$event]);
            };
        } elseif (Assert::instanceOf($handler, '\\Closure')) {
            $this->handler = $handler;
        } else {
            throw new InvalidArgumentException('`Listener::$handler` must be `array` or `Closure`');
        }
    }
769246
public function addAction(string $hook, ComponentInterface $component, string $handler, int $priority = 10, int $argCount = 1): void {
		$this->actions[] = new Hook($hook, $component, $handler, $priority, $argCount);
	}