Detect the controller for a given route and then execute the action
that is specified in the route.
430178
public function detectAndExecute()
    {
        // Get the controller
        if (!($controller = $this->detectController())) {
            return false;
        }

        // Get the action
        $action = $this->detectAction();
        if (!$action || !method_exists($controller, $action)) {
            return false;
        }

        // Get the id
        $id = $this->detectId();

        // Tell other classes what was found
        $event = Event::fire('wildcard.detection', [
            $controller, $action, $id
        ]);

        // Instantiate controller
        $controller = new $controller();
        if ($parent = $this->detectParent()) {
            list($parent_slug, $parent_id) = $parent;
            $parent_model = 'App\\'.Str::singular(Str::studly($parent_slug));
            $controller->parent($parent_model::findOrFail($parent_id));
        }

        // Execute the request
        $params = $id ? [$id] : [];
        return $controller->callAction($action, $params);
    }
341598
public function dispatch(Route $route, $controller, $method)
    {
        $parameters = $this->resolveClassMethodDependencies(
            $route->parametersWithoutNulls(), $controller, $method
        );

        if (method_exists($controller, 'callAction')) {
            return $controller->callAction($method, $parameters);
        }

        return call_user_func_array(array($controller, $method), $parameters);
    }
1241315
protected function InstanciateController($controllerClass, Route $route) {
        try {
            return new $controllerClass($this, $route->module(), $route->action());
        } catch (\Exception $exc) {
            $this->error->LogError($exc);
            throw new \Exception("Controller not loaded", Enums\ErrorCodes\FrameworkControllerConstants::ControllerNotLoadedValue, $exc);
        }
    }
349617
function run(route, index, path, query, res, next) {
    mm.create(route.action).then(
        function (presenter) {
            var ele = new Element('div');

            function finish() {
                var model = presenter.model;
                res.html = ele.outerHTML;
                res.data = model.store;
                res.routeIndex = index;
                next();
            }

            presenter
                .enter(ele, path, query)
                .then(finish, next);
        },
        next
    ).then(null, next);
}
939735
private function route() : void
    {
        // Parse route
        $parsed = $this->parseRoute();

        // Run error controller when no route matched
        if (!$parsed && isset($this->error_controller)) {
            call_user_func($this->error_controller);
        }
    }
431585
public function detectAction()
    {

        // If the path ends in one of the special actions, use that as the action
        // as long as the verb is a GET
        if (preg_match('#[a-z-]+$#i', $this->path, $matches)) {
            $action = $matches[0];

            // If posting to the create/edit route, treat as a 'post' route rather than
            // a 'create/edit' one.  This is a shorthand so the create forms can
            // post to themselves
            if ($action == 'create' && $this->verb == 'POST') {
                return 'store';
            } elseif ($action == 'edit' && $this->verb == 'POST') {
                return 'update';
            }

            // ... otherwise, use the route explicitly
            elseif (in_array($action, $this->actions)) {
                return $action;
            }
        }

        // If the path ends in a number, the verb defines what it is
        if (preg_match('#\d+$#', $this->path)) {
            switch ($this->verb) {
                case 'PUT':
                case 'POST':
                    return 'update';

                case 'DELETE':
                    return 'destroy';

                default:
                    return false;
            }
        }

        // Else, it must end with the controller name
        switch ($this->verb) {
            case 'POST':
                return 'store';

            case 'GET':
                return 'index';
        }

        // Must have been an erorr if we got here
        return false;
    }
4138
private static function routeAction()
    {
        $actionQueryString = Request::getInputValue("do", false, true);
        $actionQuery = Actions::parseActionQueryString($actionQueryString);
        
        Addons::executeComponentFunction($actionQuery->name, $actionQuery->method, @$actionQuery->arguments);
    }
134750
public function dispatch(Route $route, Request $request, $controller, $method)
	{
		// First we will make an instance of this controller via the IoC container instance
		// so that we can call the methods on it. We will also apply any "after" filters
		// to the route so that they will be run by the routers after this processing.
		$instance = $this->makeController($controller);

		$this->assignAfter($instance, $route, $request, $method);

		$response = $this->before($instance, $route, $request, $method);

		// If no before filters returned a response we'll call the method on the controller
		// to get the response to be returned to the router. We will then return it back
		// out for processing by this router and the after filters can be called then.
		if (is_null($response))
		{
			$response = $this->call($instance, $route, $method);
		}

		return $response;
	}
573498
def execute(self, request, target_route):
		
		presenter = self.create_presenter(request, target_route)
		presenter_name = target_route.presenter_name()
		action_name = target_route.presenter_action()
		presenter_args = target_route.presenter_args()

		if hasattr(presenter, action_name) is False:
			raise RuntimeError('No such action "%s" for "%s" presenter' % (action_name, presenter_name))

		action = getattr(presenter, action_name)
		if ismethod(action) is False:
			raise RuntimeError(
				'Unable to execute "%s" action for "%s" presenter' % (action_name, presenter_name)
			)

		args_spec = getfullargspec(action)
		defaults = len(args_spec.defaults) if args_spec.defaults is not None else 0
		action_args = list()
		action_kwargs = dict()

		for i in range(len(args_spec.args)):
			arg = args_spec.args[i]
			if arg == 'self':
				continue

			is_kwarg = i >= (len(args_spec.args) - defaults)

			if is_kwarg is False:
				action_args.append(presenter_args[arg])
			elif arg in presenter_args:
				action_kwargs[arg] = presenter_args[arg]

		return action(*action_args, **action_kwargs)
780082
private static function actionContext($route) {
        $httpContext = self::$config['httpContext'];
        $response = $httpContext->getResponse();

        // TODO: kill constants
        if (!defined('PHPMVC_CONTROLLER')) { define('PHPMVC_CONTROLLER', ucfirst($route->getValueOrDefault('controller', 'Home'))); }
        if (!defined('PHPMVC_ACTION')) { define('PHPMVC_ACTION', $route->getValueOrDefault('action', 'index')); }
        if (!defined('PHPMVC_VIEW')) { define('PHPMVC_VIEW', strtolower(PHPMVC_CONTROLLER)); }
        if (!defined('PHPMVC_CURRENT_CONTROLLER_PATH')) { define('PHPMVC_CURRENT_CONTROLLER_PATH', PHPMVC_CONTROLLER_PATH . PHPMVC_VIEW . PHPMVC_DS); }
        if (!defined('PHPMVC_CURRENT_VIEW_PATH')) { define('PHPMVC_CURRENT_VIEW_PATH', PHPMVC_VIEW_PATH . PHPMVC_VIEW . PHPMVC_DS . PHPMVC_ACTION . '.php'); }

        $controllerClassName = '\\' . PHPMVC_APP_NAMESPACE . '\\Controllers\\' . PHPMVC_CONTROLLER . 'Controller';

        if (!class_exists($controllerClassName)) {
            $response->setStatusCode(404);
            $response->end();
            return null;
        }

        // create action context
        $actionContext = new ActionContext($httpContext);
        InternalHelper::setPropertyValue($actionContext, 'actionName', PHPMVC_ACTION);

        // preparing to create an instance of the controller class
        $controllerClass = new \ReflectionClass($controllerClassName);
        
        if (!$controllerClass->isSubclassOf('\\PhpMvc\\Controller')) {
            throw new \Exception('The controller type must be the base of "\\PhpMvc\\Controller".');
        }

        $actionContextProperty = $controllerClass->getParentClass()->getProperty('actionContext');
        $actionContextProperty->setAccessible(true);

        // set action context
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\Model', 'actionContext', $actionContext);
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\Filter', 'actionContext', $actionContext);
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\OutputCache', 'actionContext', $actionContext);
        InternalHelper::setStaticPropertyValue('\\PhpMvc\\ValidateAntiForgeryToken', 'actionContext', $actionContext);

        // create instance of controller
        if ($controllerClass->getConstructor() != null) {
            $controllerInstance = $controllerClass->newInstance();
        }
        else {
            $controllerInstance = $controllerClass->newInstanceWithoutConstructor();
        }

        $actionContextProperty->setValue($controllerInstance, $actionContext);

        InternalHelper::setPropertyValue($actionContext, 'controller', $controllerInstance);

        if (!method_exists($controllerInstance, PHPMVC_ACTION)) {
            $response->setStatusCode(404);
            $response->end();
            return null;
        }

        // get and set model annotations
        $annotations = InternalHelper::getStaticPropertyValue('\\PhpMvc\\Model', 'annotations');
        $modelState = $actionContext->getModelState();
        $modelState->annotations = $annotations;
        // InternalHelper::setPropertyValue($modelState, 'annotations', $annotations);

        // response handling
        $response->setFlushHandler(function($eventArgs) use ($actionContext) {
            self::cachingPartial($actionContext, $eventArgs);
            self::invokeAll(self::$appContext->getFlush(), array($actionContext, $eventArgs));
        });

        $response->setEndHandler(function() use ($actionContext) {
            self::caching($actionContext);
            self::invokeAll(self::$appContext->getEnd(), array($actionContext));
        });

        $response->setPreSendHandler(function() use ($actionContext) {
            self::cachingClient($actionContext);
            self::invokeAll(self::$appContext->getPreSend(), array($actionContext));
        });

        // arguments and model state
        self::makeActionState($actionContext);

        // invoke custom handlers
        self::invokeAll(self::$appContext->getActionContextInit(), array($actionContext));

        return $actionContext;
    }
450255
public function run()
    {
        if ($this->route === null && Cii::$app->controller !== null) {
            $this->route = Cii::$app->controller->getRoute();
        }
        if ($this->params === null) {
            $this->params = Cii::$app->request->getQueryParams();
        }
        $posDefaultAction = strpos($this->route, Cii::$app->controller->defaultAction);
        if ($posDefaultAction) {
            $this->noDefaultAction = rtrim(substr($this->route, 0, $posDefaultAction), '/');
        } else {
            $this->noDefaultAction = false;
        }
        $posDefaultRoute = strpos($this->route, Cii::$app->controller->module->defaultRoute);
        if ($posDefaultRoute) {
            $this->noDefaultRoute = rtrim(substr($this->route, 0, $posDefaultRoute), '/');
        } else {
            $this->noDefaultRoute = false;
        }
        $items = $this->normalizeItems($this->items, $hasActiveChild);
        if (!empty($items)) {
            $options = $this->options;
            $tag = ArrayHelper::remove($options, 'tag', 'ul');
            echo Html::tag($tag, $this->renderItems($items), $options);
        }
    }
575001
public function performAction($controller, $action) {
		// Replace namespace with directory separator
		$controllerFile = str_replace("\\", DIRECTORY_SEPARATOR, $controller);

		// Check if controller exists
		if ( false == is_file( $controllerLocation = APP . 'Controllers/' . $controllerFile . '.php' ) )
			throw new ControllerNotFoundException();

		// Include and init the controller
		$controllerClass = "\\Application\\Controllers\\{$controller}";
		$controllerObj = new $controllerClass($this);

		// Check if the action exists
		if ( 'Errors' != $controller && false == method_exists($controllerObj, $action.= "Action" ) )
			throw new ActionNotFoundException();
		// Check if the error display action exists
		elseif ( $controller == $this->defaultRoute['_controller'] && false == method_exists($controllerObj, $action = "display" . $action ) )
			throw new ErrorActionNotFoundException();

		// Run the action
		$data = $controllerObj->{$action}();

		// Data fetching
		if ( false === $controllerObj->__returnActionPerformed ):
			// Format returned data
			if ( false == is_array( $data ) )
				$data = (array) $data;

			// Start reflection for data loading
			$ref = new \ReflectionObject($controllerObj);
			$properties = $ref->getProperties(\ReflectionProperty::IS_PUBLIC);
			$controllerData = array();

			// Get public data
			foreach ( $properties as $property ):
				// Don't add internal variabels
				if ( '__returnActionPerformed' == $property->getName() )
					continue;

				// Add property to controller data
				$controllerData[$property->getName()] = $property->getValue($controllerObj);
			endforeach;

			// Merge data from controller and action
			$data = array_merge($controllerData, $data);
		endif;

		// Return the object
		return $data;
	}
840878
function makeAction (controller, method, opts) {
  let action = {action: controller + '@' + method};
  return extend (action, opts);
}
915245
private function runAction()
    {
        // Get URL
        $url = $this->request->url();

        // Get route action
        $action = $this->router->getAction($url);

        // Perform the filter
        if ($action['filter']) {
            $filter = $this->router->performFilter($action['filter']);
        }

        // Check if the controller exists
        if (!isset($action) || !is_string($action['class']) || !class_exists($action['class'])) {
            throw new \Exception('Controller not found', 404);
        }

        // Create the required controller
        $controller = $this->make($action['class']);

        // Execute the required method and return the response
        return $this->response->output(call_user_func_array([$controller, $action['method']], $action['params']? : []));
    }
599488
function executeController(server, controller, req, res) {
    try {
        const promise = controller.call(server, req, res);
        if (promise && typeof promise.catch === 'function') {
            promise.catch(function(err) {
                res.status(500).send(err);
            });
        }
    } catch (err) {
        res.send(err);
    }
}
522123
public function run()
    {
        // choosing which controller action must be executed
        $sAction = $this->_chooseCurrentAction();

        // executing action which returns name of template to render
        /** @var Controller $oController */
        $oController = $this->getInstance("Controller");

        $view = $oController->getView();
        $view->sendHeaders();

        try {
            $oController->$sAction();
        } catch (SetupControllerExitException $exception) {
        } finally {
            $view->display();
        }
    }
1256637
public function execute($request)
	{
		$url = $request->getUrl();
		$path = $url->getPath();

		$match = $this->_router->lookup($path);
		return $this->_controllerFor($match->getName())->execute(
			new RoutedRequest(
				$this->_filterChain->filter($request),
					$match, $this->_router));
	}