/** * Method called after the module has been setup, but before the action * is executed. * @param Context $context */ function controllerStart($context) { if (!$this->config['enabled']) { return; } #Execute this only when it is a page controller and not when #it is a block, layout or some other type of controller if ($context->getType() != 'controller') { return; } #Put the action in lowercase to avoid it not being detected due to case $action = strtolower($context->getAction()); #Checks for user credentials and executes in case they are not valid if (!$this->isAuthorized($action)) { $this->callDenyFunction($action); $view_type = $context->getViewType(); switch ($view_type) { case 'html': case 'process': case 'mail': $this->loginRedirect(); break; case 'json': case 'feed': default: exit; } exit; } $this->started = true; }
/** * Initializes the Controller instance and selects the appropiate View * @param Context $context */ function __construct(Context $context) { $type = $context->getViewType(); $class_name = $type . 'view'; $view = new $class_name($context); parent::__construct($context, $view); $this->db = new DatabaseProxy($this->load); $this->helper = new HelperLoader($this->load); }