Ejemplo n.º 1
0
 /**
  * Load the language if the controller has not been dispatched
  *
  * @param   ControllerContext $context A controller context object
  * @return  void
  */
 protected function _beforeRender(ControllerContext $context)
 {
     $controller = $context->getSubject();
     if (!$controller->isDispatched()) {
         $controller->loadLanguage();
     }
 }
Ejemplo n.º 2
0
 /**
  * Add the toolbars to the controller
  *
  * @param ControllerContext $context
  * @return void
  */
 protected function _beforeRender(ControllerContext $context)
 {
     $controller = $context->getSubject();
     // Add toolbars on authenticated requests only.
     if ($controller->getUser()->isAuthentic()) {
         //Add the toolbars
         $toolbars = (array) ObjectConfig::unbox($this->getConfig()->toolbars);
         foreach ($toolbars as $key => $value) {
             if (is_numeric($key)) {
                 $this->addToolbar($value);
             } else {
                 $this->addToolbar($key, $value);
             }
         }
     }
     //Add the template filter and inject the toolbars
     if ($controller->getView() instanceof ViewTemplatable) {
         $controller->getView()->getTemplate()->addFilter('toolbar', array('toolbars' => $this->getToolbars()));
     }
 }
Ejemplo n.º 3
0
 /**
  * Get the controller context
  *
  * @param   ControllerContextInterface $context Context to cast to a local context
  * @return  ControllerContext
  */
 public function getContext(ControllerContextInterface $context = null)
 {
     $context = new ControllerContext($context);
     $context->setRequest($this->getRequest());
     $context->setResponse($this->getResponse());
     $context->setUser($this->getUser());
     return $context;
 }