/** * Called before the controller action. * You can use this method to perform logic that needs to happen before * each controller action. * @param \Cake\Event\Event $event An Event instance * @return void * @uses MeCms\Controller\AppController::beforeFilter() * @uses MeCms\Model\Table\UsersGroupsTable::getList() */ public function beforeFilter(\Cake\Event\Event $event) { parent::beforeFilter($event); if ($this->request->isAction(['index', 'add', 'edit'])) { $this->set('groups', $this->Users->Groups->getList()); } }
/** * Called before the controller action. * You can use this method to perform logic that needs to happen before * each controller action. * @param \Cake\Event\Event $event An Event instance * @return void * @uses MeCms\Controller\AppController::beforeFilter() * @uses MeCms\Model\Table\PagesCategoriesTable::getTreeList() */ public function beforeFilter(\Cake\Event\Event $event) { parent::beforeFilter($event); if ($this->request->isAction(['add', 'edit'])) { $this->set('categories', $this->PagesCategories->getTreeList()); } }
/** * Initialization hook method * @return void * @uses MeCms\Controller\AppController::initialize() */ public function initialize() { parent::initialize(); //Loads KcFinderComponent if ($this->request->isAction(['add', 'edit'])) { $this->loadComponent('MeCms.KcFinder'); } }
/** * Called after the controller action is run, but before the view is * rendered. * You can use this method to perform logic or set view variables that * are required on every request. * @param \Cake\Event\Event $event An Event instance * @return void * @see http://api.cakephp.org/3.3/class-Cake.Controller.Controller.html#_beforeRender */ public function beforeRender(\Cake\Event\Event $event) { parent::beforeRender($event); //Uses a custom View class (`MeYoutube.AppView` or `MeCms.AdminView`) if ($this->request->isAdmin()) { $this->viewBuilder()->className('MeCms.View/Admin'); } else { $this->viewBuilder()->className('MeYoutube.View/App'); } }
/** * Called after the controller action is run, but before the view is * rendered. * You can use this method to perform logic or set view variables that * are required on every request. * @param \Cake\Event\Event $event An Event instance * @return void * @see http://api.cakephp.org/3.3/class-Cake.Controller.Controller.html#_beforeRender * @uses MeCms\Controller\AppController::beforeRender() * @uses MeInstagram\Utility\Instagram::user() */ public function beforeRender(\Cake\Event\Event $event) { parent::beforeRender($event); //Tries to get data from the cache $user = Cache::read($cache = 'user_profile', 'instagram'); //If the data are not available from the cache if (empty($user)) { $user = Instagram::user(); Cache::write($cache, $user, 'instagram'); } $this->set(compact('user')); }
/** * Called before the controller action. * You can use this method to perform logic that needs to happen before * each controller action. * @param \Cake\Event\Event $event An Event instance * @return \Cake\Network\Response|null|void * @uses MeCms\Controller\AppController::beforeFilter() * @uses MeCms\Model\Table\PhotosAlbums::getList() */ public function beforeFilter(\Cake\Event\Event $event) { parent::beforeFilter($event); if ($this->request->isAction(['index', 'edit', 'upload'])) { //Gets albums $albums = $this->Photos->Albums->getList(); //Checks for albums if (empty($albums) && !$this->request->isIndex()) { $this->Flash->alert(__d('me_cms', 'You must first create an album')); return $this->redirect(['controller' => 'PhotosAlbums', 'action' => 'index']); } $this->set(compact('albums')); } }
/** * Called before the controller action. * You can use this method to perform logic that needs to happen before * each controller action. * @param \Cake\Event\Event $event An Event instance * @return \Cake\Network\Response|null|void * @uses MeCms\Controller\AppController::beforeFilter() * @uses MeCms\Model\Table\BannersPositions::getList() */ public function beforeFilter(\Cake\Event\Event $event) { parent::beforeFilter($event); if ($this->request->isAction(['index', 'edit', 'upload'])) { //Gets positions $positions = $this->Banners->Positions->getList(); //Checks for positions if (empty($positions) && !$this->request->isIndex()) { $this->Flash->alert(__d('me_cms', 'You must first create a banner position')); return $this->redirect(['controller' => 'BannersPositions', 'action' => 'index']); } $this->set(compact('positions')); } }
/** * Called before the controller action. * You can use this method to perform logic that needs to happen before * each controller action. * @param \Cake\Event\Event $event An Event instance * @return void * @see http://api.cakephp.org/3.3/class-Cake.Controller.Controller.html#_beforeFilter * @uses MeCms\Controller\AppController::beforeFilter() */ public function beforeFilter(\Cake\Event\Event $event) { parent::beforeFilter($event); $this->Auth->deny('preview'); }
/** * Initialization hook method * @return void */ public function initialize() { parent::initialize(); $this->loadComponent('Cookie'); $this->loadComponent('Tokens.Token'); }