当前位置: 首页>>代码示例>>PHP>>正文


PHP Controller::beforeFilter方法代码示例

本文整理汇总了PHP中Cake\Controller\Controller::beforeFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::beforeFilter方法的具体用法?PHP Controller::beforeFilter怎么用?PHP Controller::beforeFilter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Cake\Controller\Controller的用法示例。


在下文中一共展示了Controller::beforeFilter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     //$this->Auth->allow(['view', 'index', 'checkExistence', 'edit',
     //'delete', 'add', 'twit', 'twit1', 'mention','token', 'getMention', 'mentionToDB']);
     $this->Auth->allow(['token', 'getMention']);
 }
开发者ID:aansubarkah,项目名称:apimiminmacetdimana,代码行数:7,代码来源:AppController.php

示例2: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->Auth->allow([]);
     $this->localeSite();
     $this->viewBuilder()->layout('default');
 }
开发者ID:albertoneto,项目名称:localhost,代码行数:7,代码来源:AppController.php

示例3: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->initConfig();
     $this->roles = Configure::read('roles');
     $this->set('roles', $this->roles);
     $this->statuses = Configure::read('statuses');
     $this->set('statuses', $this->statuses);
     $this->options = TableRegistry::get('Options');
     $this->set('options', $this->options->getOptions());
     Configure::write('options', $this->options->getOptions());
     /**
      * 
      *  In case the User Is Logged in make the Information of the 
      *   User Available under the view and Controller using the 
      *  $current_user Variable 
      */
     if ($this->Auth->user()) {
         $this->current_user = $this->Auth->user();
         $this->set('current_user', $this->current_user);
     }
     /**
      * 
      * Default Home Page Link for the Breadcrumbs
      */
     $this->breadcrumbs[] = array('label' => __('Home'), 'link' => ['controller' => 'pages', 'action' => 'home'], 'class' => 'fa fa-home');
 }
开发者ID:hunnybohara,项目名称:coin_bates,代码行数:27,代码来源:AppController.php

示例4: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     Time::$defaultLocale = 'en-CA';
     Time::setToStringFormat('YYYY-MM-dd');
     $this->Session = $this->request->session();
     $this->set('Session', $this->Session);
     $this->_icons = $this->Utilities->setIcons();
     $this->set('icons', $this->_icons);
     $title = $this->Utilities->setDefaultTitle();
     $breadcrumbs = $this->Utilities->setDefaultBreadcrumbs();
     $this->set(compact('title', 'breadcrumbs'));
     if (empty($this->request->params['prefix'])) {
         $this->Auth->allow();
         $this->viewBuilder()->layout('public');
     }
     // Set the user logged in
     if (!is_null($this->Auth->user('id'))) {
         $Users = TableRegistry::get('Users');
         $this->_user = $Users->get($this->Auth->user('id'));
         $this->set('authUser', $this->_user);
     } else {
         $this->set('authUser', false);
     }
     // $this->set(compact($authUser));
     $nav = $this->_setNav();
     $this->set(compact('nav'));
 }
开发者ID:BreakfastMonkey,项目名称:breakfast-combo,代码行数:28,代码来源:AppController.php

示例5: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     if (!$this->request->is('post')) {
         $this->loadComponent('Search.Prg');
     }
 }
开发者ID:mohammadsaleh,项目名称:spider,代码行数:7,代码来源:SpiderController.php

示例6: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     if ($this->Auth->user()) {
         $this->set('auth', $this->Auth->user());
     }
 }
开发者ID:ranostaj,项目名称:autocar,代码行数:7,代码来源:AppController.php

示例7: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $session = $this->request->session();
     $lang = 'en';
     if (isset($this->request->params['lang'])) {
         $lang = $this->request->params['lang'];
     } else {
         if ($session->check('Config.language')) {
             $lang = $session->read('Config.language');
         }
     }
     $session->write('Config.language', $lang);
     // Change current language by post request
     if ($this->request->is('post') && isset($this->request->data['language'])) {
         $newLang = $this->request->data['language'];
         $transUrl = $this->translateUrl($newLang);
         $this->redirect($transUrl);
     }
     $this->set('lang', $lang);
     $this->set('controller', $this->name);
     I18n::locale($lang);
     Time::setToStringFormat('YYYY-MM-dd HH:mm:ss');
     Type::build('datetime')->useLocaleParser();
     $this->Auth->config(['unauthorizedRedirect' => false]);
     $this->Auth->allow(['login', 'init']);
     $user = $this->Auth->user();
     if (isset($user)) {
         $username = $user['username'];
         $this->set(['is_authorized' => true, 'username' => $username]);
     } else {
         $this->set('is_authorized', false);
     }
 }
开发者ID:GreeNoir,项目名称:game-wizard,代码行数:34,代码来源:AppController.php

示例8: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->Auth->config('authError', "Désolé, vous n'êtes pas autorisés à accéder à cette zone.");
     $this->Auth->allow(['add', 'login']);
     $this->set('dataUser', $this->Auth->user());
 }
开发者ID:yao-dev,项目名称:blog-mvc.github.io,代码行数:7,代码来源:AppController.php

示例9: beforeFilter

 public function beforeFilter(\Cake\Event\Event $event)
 {
     parent::beforeFilter($event);
     $this->Auth->allow(['index', 'view', 'dashboard', 'register', 'verify', 'forgotPass', 'resetPass']);
     $userdata = $this->Auth->user();
     $this->user_id = $userdata['id'];
     // Temporary way to break data away from auth cache and update. Running every page = bad, though....
     $this->loadModel('Users');
     $this->loadModel('Notifications');
     if (!empty($userdata)) {
         $user = $this->Users->get($userdata['id']);
         $this->set('user_id', $user->id);
         $this->set('username', $user->username);
         $this->set('loggedin', true);
         $this->set('timezone', $user->timezone);
         $this->set('avatar', $user->avatar);
         $this->set('current_portrait', $user->current_portrait);
         $this->set('level', $user->level);
         $this->set('current_user', $user);
         $this->set('unread', $this->Notifications->findUnread($user->id)->count());
     } else {
         $this->set('loggedin', false);
         $this->set('username', false);
         $this->set('user_id', false);
         $this->set('timezone', null);
     }
 }
开发者ID:breakfastcerealkillr,项目名称:vgphotohunt,代码行数:27,代码来源:AppController.php

示例10: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $stats = NULL;
     //$this->request->find('...');
     $this->set('stats', $stats);
 }
开发者ID:RASMiranda,项目名称:seocreditos,代码行数:7,代码来源:AppController.php

示例11: beforeFilter

 /**
  * Before filter callback.
  *
  * @param CakeEvent $event
  * @return void
  */
 public function beforeFilter(CakeEvent $event)
 {
     parent::beforeFilter($event);
     Event::dispatch('App.Controller.Setup', $this);
     $this->set('page_title', implode(' ', [$this->request->param('controller'), $this->request->param('action')]));
     $this->Security->config('unlockedFields', ['action']);
 }
开发者ID:UnionCMS,项目名称:Core,代码行数:13,代码来源:AppController.php

示例12: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->Auth->allow('*');
     if ($this->Auth->user('id')) {
         $this->viewBuilder()->layout('loggedin');
     }
 }
开发者ID:ghadagesandip,项目名称:cakephp3,代码行数:8,代码来源:AppController.php

示例13: beforeFilter

 public function beforeFilter(Event $event)
 {
     if ($this->Auth->user()) {
         $this->current_user = $this->Auth->user();
         $this->isUserLoggedIn = TRUE;
     }
     parent::beforeFilter($event);
 }
开发者ID:hunnybohara,项目名称:coin_bates,代码行数:8,代码来源:AppController.php

示例14: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     if ($this->Crud) {
         $this->Crud->on('setFlash', function (Event $event) {
             $event->subject()->params['class'] = str_replace('message ', 'alert alert-dismissible fade in alert-', $event->subject()->params['class']);
         });
     }
 }
开发者ID:andrej-griniuk,项目名称:Neuron,代码行数:9,代码来源:AppController.php

示例15: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->_setLanguage();
     $language = $this->request->session()->read('Config.language');
     I18n::locale($language);
     if (!$this->request->session()->check('User') && $this->action == 'admin_login') {
         $this->redirect('/admin/admin_login');
     }
 }
开发者ID:TranBinhLuan,项目名称:junzeron,代码行数:10,代码来源:AppController.php


注:本文中的Cake\Controller\Controller::beforeFilter方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。