ManaPHP\Mvc\Application::handle PHP Метод

handle() публичный Метод

Handles a MVC request
public handle ( string $uri = null ) : ManaPHP\Http\ResponseInterface
$uri string
Результат ManaPHP\Http\ResponseInterface
    public function handle($uri = null)
    {
        if ($this->fireEvent('application:boot') === false) {
            return $this->response;
        }
        $this->router->handle($uri, null, false);
        $moduleName = ucfirst($this->router->getModuleName());
        $controllerName = $this->router->getControllerName();
        $actionName = $this->router->getActionName();
        $params = $this->router->getParams();
        $this->alias->set('@views', "@app/{$moduleName}/Views");
        $this->alias->set('@messages', "@app/{$moduleName}/Messages");
        $this->alias->set('@ns.module', '@ns.app\\' . $moduleName);
        $this->alias->set('@ns.controllers', '@ns.module\\Controllers');
        $this->alias->set('@ns.widgets', '@ns.module\\Widgets');
        $moduleClassName = $this->alias->resolve('@ns.module\\Module');
        $eventData = ['module' => $moduleName];
        $this->fireEvent('application:beforeStartModule', $eventData);
        $this->_moduleObject = $this->_dependencyInjector->getShared($moduleClassName);
        $this->_moduleObject->registerServices($this->_dependencyInjector);
        $eventData = ['module' => $moduleName];
        $this->fireEvent('application:afterStartModule', $eventData);
        $handler = [$this, '_eventHandlerBeforeExecuteRoute'];
        $this->dispatcher->attachEvent('dispatcher:beforeExecuteRoute', $handler);
        $ret = $this->dispatcher->dispatch($moduleName, $controllerName, $actionName, $params);
        if ($ret === false) {
            return $this->response;
        }
        $actionReturnValue = $this->dispatcher->getReturnedValue();
        if ($actionReturnValue === null || is_string($actionReturnValue)) {
            $this->view->setContent($actionReturnValue);
            $this->view->render($this->dispatcher->getControllerName(), $this->dispatcher->getActionName());
            $this->response->setContent($this->view->getContent());
        }
        return $this->response;
    }