Invoke action method.

@param \ReflectionMethod $actionMethod The action method.
@param array             $parameters   The parameters.

@return mixed|null The result.
427600
private function invokeActionMethod(\ReflectionMethod $actionMethod, array $parameters)
    {
        $this->actionMethod = $actionMethod;

        // Handle pre-action event.
        $preActionResult = $this->isPreActionEventEnabled() ? $this->onPreActionEvent() : null;
        if ($preActionResult !== null) {
            return $preActionResult;
        }

        // Handle action method.
        $result = $actionMethod->invokeArgs($this, $parameters);

        // Handle post-action event.
        $postActionResult = $this->isPostActionEventEnabled() ? $this->onPostActionEvent() : null;
        if ($postActionResult !== null) {
            return $postActionResult;
        }

        return $result;
    }
321006
public function invokeAction($action, $params = [])
    {

        //var_dump($this->request->getAttributes());

        //Will throw an exception if the method does not exists;
        $method = new ReflectionMethod($this, $action);

        if (!$method->isPublic()) {
            throw new Exception('Attempting to call a private method');
        }

        return $method->invokeArgs($this, $params);

    }
168059
public function invokeAction($controller, $action, $params)
    {
        $actionMethod = $action . 'Action';

        if (!method_exists($controller, $actionMethod)) {
            throw new NotFoundActionException([
                '`:controller:::action` method does not exist',
                'action' => $actionMethod,
                'controller' => get_class($controller)
            ]);
        }

        $this->eventsManager->fireEvent('request:authorize', $this);

        $this->eventsManager->fireEvent('request:validate', $this, ['controller' => get_class($controller), 'action' => $action]);

        $this->eventsManager->fireEvent('request:ready', $this);

        $this->eventsManager->fireEvent('request:invoke', $this, $action);

        $args = $this->_buildActionArgs($controller, $action, $params);

        switch (count($args)) {
            case 0:
                $r = $controller->$actionMethod();
                break;
            case 1:
                $r = $controller->$actionMethod($args[0]);
                break;
            case 2:
                $r = $controller->$actionMethod($args[0], $args[1]);
                break;
            case 3:
                $r = $controller->$actionMethod($args[0], $args[1], $args[2]);
                break;
            default:
                $r = call_user_func_array([$controller, $actionMethod], $args);
                break;
        }

        $this->eventsManager->fireEvent('request:invoked', $this, ['action' => $action, 'return' => $r]);

        return $r;
    }
988614
final public function invokeAction()
    {
        $time = time();
        $success = $this->doAction();
        $this->actionRequired = !$success;
        $this->lastActionSuccess = $success;
        $this->lastActionAttemptTime = $time;

        if ($success) {
            $this->lastActionSuccessTime = $time;
        } else {
            $this->lastActionFailTime = $time;
        }

        return $success;
    }
479436
protected function _autoaction($var, $httpMethod = 'get')
    {
        $method = $this->urlToActionName($var, $httpMethod);
        if (method_exists($this, $method)) {
            return $this->$method();
        } else {
            ToroHook::fire('404', array(
                "error" => "Controller ".get_class($this)." does not contain $method action",
                "path_info" => $this->_pathInfo ));
        }
    }
1034178
private function callAction($controller, $actionName, $request = null)
    {
        if (method_exists($controller, $actionName)) {
            $context = $controller->$actionName($request);
            if ($context == null) {
                $context = [];
            }
            return $context;
        }
        throw new PageNotFoundException("Method " . $actionName . " not found!");
    }
903766
public function doAction($actionName)
    {
        if (isset($this->actions[$actionName]))
            return call_user_func_array(array($this, $this->actions[$actionName]), array());
    }
77846
public function loadMetadataForAction($controllerClassName, $actionMethod)
    {
        $key = $controllerClassName . '_' . $actionMethod;
        if (array_key_exists($key, $this->classAnnotations)) {
            return $this->classAnnotations[$key];
        }

        $r = new \ReflectionClass($controllerClassName);
        $rMethod = $r->getMethod($actionMethod);

        $metadata = new Metadata();


        /** @var Annotation\WorkflowDispatch|null $workflowDispatchAnnotation */
        $workflowDispatchAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\WorkflowDispatch::class);
        if (null !== $workflowDispatchAnnotation) {
            $metadata->setWorkflowDispatch($workflowDispatchAnnotation->enabled);
            $metadata->setWorkflowRunType($workflowDispatchAnnotation->activity);
        }

        /** @var Annotation\PrepareData|null $prepareDataAnnotation */
        $prepareDataAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\PrepareData::class);
        if ($prepareDataAnnotation) {
            $metadata->setFlagRunPrepareData($prepareDataAnnotation->enabled);
            $metadata->setPrepareDataMethod($prepareDataAnnotation->type);
            $metadata->setPrepareDataHandler($prepareDataAnnotation->handler);
        }


        /** @var Annotation\DispatchConditions|null $dispatchConditionsAnnotation */
        $dispatchConditionsAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\DispatchConditions::class);
        if ($dispatchConditionsAnnotation && is_array($dispatchConditionsAnnotation->conditions) && count($dispatchConditionsAnnotation->conditions) > 0) {
            $metadata->setFlagHasConditions(true);
            foreach ($dispatchConditionsAnnotation->conditions as $condition) {
                if (!$condition instanceof Condition) {
                    $errMsg = 'Invalid condition annotation';
                    throw new Exception\AnnotationReaderException($errMsg);
                }
                $conditionMetadata = new DispatchConditionMetadata($condition->type, $condition->handler, $condition->params);

                $metadata->addConditions($conditionMetadata);
            }
        }
//
//        /** @var Annotation\WorkflowRouterMap|null $workflowRouterMapAnnotation */
//        $workflowRouterMapAnnotation = $this->getReader()->getMethodAnnotation($rMethod, Annotation\WorkflowRouterMap::class);
//        if ($workflowRouterMapAnnotation) {
//            $metadata->setWorkflowManagerNameRouterParam($workflowRouterMapAnnotation->managerName);
//            $metadata->setWorkflowActionNameRouterParam($workflowRouterMapAnnotation->actionName);
//            $metadata->setWorkflowNameRouterParam($workflowRouterMapAnnotation->name);
//            $metadata->setEntryIdRouterParam($workflowRouterMapAnnotation->entryId);
//        }
//
//        $metadata->validate();

        return $metadata;
    }
29282
protected function tryCall($method, array $parameters): bool
    {
        $called = parent::tryCall($method, $parameters);
        if (!$called && substr($method, 0, 6) === 'action') {
            $class = get_class($this);
            throw new BadRequestException("Action '$class::$method' does not exist.");
        }

        return $called;
    }
1090065
public function invoke($method, $parameters)
    {
        /* @var Aop $aop */
        $aop = \bean(Aop::class);

        return $aop->execute($this->target, $method, $parameters);
    }
740754
public function callAction($method, $parameters)
    {
        $this->responseArray['type'] = Response::TYPE_CONTENT;
        $this->responseArray['method'] = Request::method();
        $this->responseArray['code'] = Response::NO_ERROR;

        if (isset($this->requiredFields[$method]) and is_array($this->requiredFields[$method])) {
            $this->validateParameters($this->requiredFields[$method]);
        }

        $response = parent::callAction($method, $parameters);

        if ($response instanceof RedirectResponse) {
            $this->responseArray['type'] = Response::TYPE_REDIRECT;
            $this->responseArray['targetUrl'] = $response->getTargetUrl();
            $this->responseArray['code'] = $response->getStatusCode();
        } else {
            if ($response instanceof View) {
                return new JsonResponse($response->render());
            } else {
                if ($response instanceof JsonResponse) {
                    return $response;
                }
            }
        }

        return (new Response(config('app.debug')))->createResponse($this->responseArray);
    }
1303698
protected function execute($method, array $actionManagers)
    {
        $actions = array('post' => array(), 'notExecuted' => array());
        foreach ($actionManagers as $bundleName => $actionManager) {
            $this->actionManagerGenerator->generate($actionManager);
            $actionManagerClass = $this->actionManagerGenerator->getActionManagerClass();
            $actionManager = $this->actionManagerGenerator->getActionManager();
            if (null !== $actionManager && false === $actionManager->$method()) $actions['notExecuted'][$bundleName] = $actionManagerClass;
            $actions['post'][$bundleName] = $actionManagerClass;
        }

        return $actions;
    }
65223
public function call($callback, array $parameters = [], $defaultMethod = null)
    {
        return BoundMethod::call($this, $callback, $parameters, $defaultMethod);
    }
711598
private function invokeMethod()
    {
        if ($this->located_controller === NULL)
        {
            throw new Exception('404 Not Found.');
        }

        $class = "App\\Controller\\" . $this->located_controller;

        if (!class_exists($class))
        {
            throw new Exception("$class class not found.");
        }

        $controller = new $class;
        if (method_exists($controller, $this->located_method))
        {
            $reflection = new ReflectionMethod($controller, $this->located_method);

            # Perpareing method parameter from remaining url.
            $parameter = array();
            $index = 0;
            foreach ($reflection->getParameters() as $param)
            {
                if (array_key_exists($index, $this->remaining_uri))
                {
                    $parameter[$index] = $this->remaining_uri[$index];
                }
                else if ($param->isOptional())
                {
                    $parameter[$index] = $param->getDefaultValue();
                }
                else
                {
                    throw new Exception('Not found.');
                }
                $index++;
            }

            $reflection->invokeArgs($controller, $parameter);
        }
    }
70552
final public static function execute(Parameters $params) {

        $asked_method = $params->get('method');

        $method = $params->methods()->get($asked_method);

        if ( is_null($method) ) throw new RpcException("Method not found", -32601);

        return $method->getDescription();

    }
1010075
public function invoke($uri, $method, $parameters = array())
    {
        // Request URI.
        if ( ! preg_match('/^http(s)?:/', $uri))
        {
            $uri = '/'.ltrim($uri, '/');
        }

        try
        {
            // Store the original request data and route.
            $originalInput = $this->request->input();
            $originalRoute = $this->router->getCurrentRoute();

            // Masking route to allow testing with PHPUnit.
            if ( ! $originalRoute instanceof Route)
            {
                $originalRoute = new Route(new \Symfony\Component\HttpFoundation\Request());
            }

            // Create a new request to the API resource
            $request = $this->request->create($uri, strtoupper($method), $parameters);

            // Replace the request input...
            $this->request->replace($request->input());

            // Dispatch request.
            $dispatch = $this->router->dispatch($request);

            if (method_exists($dispatch, 'getOriginalContent'))
            {
                $response = $dispatch->getOriginalContent();
            }
            else
            {
                $response = $dispatch->getContent();
            }

            // Decode json content.
            if ($dispatch->headers->get('content-type') == 'application/json')
            {
                if (function_exists('json_decode') and is_string($response))
                {
                    $response = json_decode($response, true);
                }
            }

            // Restore the request input and route back to the original state.
            $this->request->replace($originalInput);


            // This method have been removed from Laravel.
            //$this->router->setCurrentRoute($originalRoute);

            return $response;
        }
        catch (NotFoundHttpException $e)
        {
            //trigger_error('Not found');
            var_dump($e->getMessage());
        }
        catch (FatalErrorException $e)
        {
            var_dump($e->getMessage());
        }
    }
180798
public function call(callable $callable, array $parameters = [])
	{
		if(is_array($callable))
		{
			$reflection = new ReflectionMethod($callable[0], $callable[1]);
		}
		else
		{
			$reflection = new ReflectionFunction($callable);
		}

		return $callable(...$this->resolveParameters($reflection->getParameters(), $parameters));
	}