luya\base\ModuleReflection::run PHP Method

run() public method

Run the route based on the values.
public run ( ) : string | Response
return string | yii\web\Response The response of the action, can be either a string or an object from response.
    public function run()
    {
        // request route
        $requestRoute = $this->getRequestRoute();
        // create controller object
        $controller = $this->module->createController($requestRoute['route']);
        // throw error if the requests request does not returns a valid controller object
        if (!isset($controller[0]) && !is_object($controller[0])) {
            throw new NotFoundHttpException(sprintf("Unable to create controller '%s' for module '%s'.", $requestRoute['route'], $this->module->id));
        }
        Yii::info('LUYA module run module "' . $this->module->id . '" route ' . $requestRoute['route'], __METHOD__);
        /**
         * issue: https://github.com/zephir/luya/issues/754
         *
         * As the route resolving should not contain empty argument list we overload the $requertRoute['args'] if they are empty
         * with the whole get params
         */
        if (empty($requestRoute['args'])) {
            $requestRoute['args'] = $this->request->get();
        }
        $this->controller = $controller[0];
        // run the action on the provided controller object
        return $this->controller->runAction($controller[1], $requestRoute['args']);
    }