beforeAction() protected method

Sets up various standard js and css files for modules.
protected beforeAction ( CAction $action ) : boolean
$action CAction
return boolean (non-phpdoc)
 /**
  * Setup base css/js etc requirements for the eventual action render.
  *
  * @param $action
  * @return bool
  * @throws CHttpException
  * @see parent::beforeAction($action)
  */
 protected function beforeAction($action)
 {
     // Automatic file inclusion unless it's an ajax call
     if ($this->assetPath && !Yii::app()->getRequest()->getIsAjaxRequest()) {
         if (!$this->isPrintAction($action->id)) {
             // nested elements behaviour
             //TODO: possibly put this into standard js library for events
             Yii::app()->getClientScript()->registerScript('nestedElementJS', 'var moduleName = "' . $this->getModule()->name . '";', CClientScript::POS_HEAD);
             Yii::app()->assetManager->registerScriptFile('js/nested_elements.js');
         }
     }
     $this->setFirmFromSession();
     if (!isset($this->firm)) {
         // No firm selected, reject
         throw new CHttpException(403, 'You are not authorised to view this page without selecting a firm.');
     }
     $this->initAction($action->id);
     $this->verifyActionAccess($action);
     return parent::beforeAction($action);
 }
Exemplo n.º 2
0
 /**
  * Ensures firm is set on the controller.
  *
  * @param \CAction $action
  *
  * @return bool
  */
 protected function beforeAction($action)
 {
     $this->setFirmFromSession();
     return parent::beforeAction($action);
 }