public function init() { $uri = new Uri(); $router = new Router($uri); $routeRule = $router->findRoute(); $this->currentController = $routeRule->getController(); $this->requestContext->setCurrentController($this->currentController); $this->currentAction = $routeRule->isActionRequired() ? $routeRule->getAction() : $uri->getAction(); $this->sessionInitializer->startSession(); $this->currentControllerObject = $this->controllerFactory->createController($routeRule); $this->requestContext->setCurrentControllerObject($this->currentControllerObject); $this->_logRequest(); $afterInitCallback = Config::getValue('callback', 'afterControllerInit'); if ($afterInitCallback) { Functions::call($afterInitCallback, array()); } try { ob_start(); $this->_invokeControllerMethods(); } catch (Exception $e) { ob_end_clean(); throw $e; } ob_end_flush(); }
/** * @test */ public function shouldReturnEmptyArrayWhenParsePathIsNull() { //given $this->_path(null); //when $path = $this->uri->getAction(); //then $this->assertNull($path); }
public function initialize(RouteRule $routeRule) { $this->_routeRule = $routeRule; $uri = new Uri(); $this->currentController = $routeRule->getController(); $this->currentAction = $routeRule->isActionRequired() ? $routeRule->getAction() : $uri->getAction(); $viewName = $this->getViewName(); $this->view = new View($viewName); $this->layout = new Layout($this->view); $this->params = $this->createParameters($routeRule, $uri); }