/** * Calls authorize and prepare in this order. * The ControllerFactory calls initialize when creating a controller, if $skipInitialization == false * * If you skip it, make sure you call all methods yourself! * * * @see authorize() * @see prepare() * @see ErrorMessageException */ public final function initialize() { $this->router->setCurrentRoute($this->getUrlName(), $this->getUrlAction(), $this->getActionParameters()); if (($error = $this->router->getUrlError()) !== null) { $this->addError($error); } if (($success = $this->router->getUrlSuccess()) !== null) { $this->addSuccess($success); } try { $this->authorize(); $this->prepare(); } catch (DatabaseException $e) { Log::error($e->getMessage(), 'Controller', array('siteName' => $this->getSiteName())); throw new ControllerException('Database error.'); } if ($this->keepInHistory()) { $this->container->history->addUrl($this->router->getUrl()); } }