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


PHP AppController::beforeFilter方法代码示例

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


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

示例1: beforeFilter

 /**
  * beforeFilter callback
  *
  * @param
  * @return void
  */
 public function beforeFilter(\Cake\Event\Event $event)
 {
     parent::beforeFilter($event);
     $this->layout = 'public';
     $this->loadModel('Posts');
     $this->Auth->allow();
 }
开发者ID:rafaelqueiroz,项目名称:welovecakephp,代码行数:13,代码来源:PagesController.php

示例2: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->loadModel('Financialquarters');
     $this->loadModel('PartnerManagers');
     $this->layout = 'admin';
 }
开发者ID:franky0930,项目名称:MarketingConnex,代码行数:7,代码来源:PartnersController.php

示例3: beforeFilter

 /**
  * @param \Cake\Event\Event $event Event object.
  * @return void
  */
 public function beforeFilter(Event $event)
 {
     if ($this->Auth) {
         $this->Auth->allow(['oauth', 'authorize', 'accessToken']);
     }
     parent::beforeFilter($event);
 }
开发者ID:surjit,项目名称:oauth-server,代码行数:11,代码来源:OAuthController.php

示例4: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     if (!in_array($this->request->param('action'), ['login', 'logout', 'register'])) {
         $user = $this->Auth->User();
         if (!empty($user)) {
             if ($this->isAdmin($user)) {
                 return $this->redirect(['prefix' => 'admin', 'controller' => 'Users', 'action' => 'index']);
             }
         }
     }
     // Allow users to register and logout.
     // You should not add the "login" action to allow list. Doing so would
     // cause problems with normal functioning of AuthComponent.
     $this->Auth->allow(['register', 'logout']);
     if (in_array($this->request->param('action'), ['register', 'login'])) {
         $this->layout = 'form';
     }
     if (in_array($this->request->param('action'), ['index', 'update_info', 'view'])) {
         $this->layout = 'dashboard';
     }
     if (strcmp($this->request->params['action'], 'login') === 0) {
         if (!empty($user)) {
             return $this->_goToDashboard($user);
         }
     }
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:27,代码来源:UsersController.php

示例5: beforeFilter

 public function beforeFilter(\Cake\Event\Event $event)
 {
     parent::beforeFilter($event);
     $this->adminOnly(['action' => 'index']);
     $pageLimit = 10;
     $this->set('pageLimit', $pageLimit);
 }
开发者ID:breakfastcerealkillr,项目名称:vgphotohunt,代码行数:7,代码来源:AdminController.php

示例6: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->layout = 'dashboard';
     $this->Upload->uploadDir .= DS . Time::now()->i18nFormat('YYYY/MM/dd');
     $this->Upload->fileVar = 'file';
     if (in_array($this->request->param('action'), ['upload']) && $this->request->is('post')) {
         $data = $this->request->data;
         if (empty($data['file'])) {
             $this->Upload->fileVar = 'thumbnail_url';
         }
         $name = $data[$this->Upload->fileVar]['name'];
         if (empty($data['title'])) {
             $data['title'] = str_replace('-', ' ', $this->_toSlug(pathinfo($name)['filename']));
         }
         $data['title'] = ucfirst($data['title']);
         if (empty($data['slug'])) {
             $data['slug'] = $this->autoSlug($data['title']);
         }
         $data[$this->Upload->fileVar]['name'] = $this->__processFileName($data[$this->Upload->fileVar]['name']);
         $data[$this->Upload->fileVar]['name'] = $data['slug'] . '-' . Time::now()->i18nFormat('YYYY-MM-dd');
         //            $img_size = getimagesize($data[$this->Upload->fileVar]['tmp_name']);
         //            if ($img_size) {
         //                $data[$this->Upload->fileVar]['name'] .= '-w' . $img_size[0] . '-h' . $img_size[1] . '-' . md5_file($data["file"]["tmp_name"]);
         //            }
         $data[$this->Upload->fileVar]['name'] .= '.' . pathinfo($name)['extension'];
         $this->request->data = $data;
     }
 }
开发者ID:ansidev,项目名称:cakephp_blog,代码行数:29,代码来源:MediaController.php

示例7: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->layout = 'admin';
     $this->loadModel('PartnerMailinglists');
     $this->loadModel('PartnerMailinglistSegmentRules');
 }
开发者ID:franky0930,项目名称:MarketingConnex,代码行数:7,代码来源:PartnerMailinglistSegmentsController.php

示例8: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     // Allow users to register and logout.
     $this->Auth->allow(['index']);
     //$this->loadComponent('Socialmedia');
 }
开发者ID:franky0930,项目名称:MarketingConnex,代码行数:7,代码来源:TestController.php

示例9: beforeFilter

 public function beforeFilter(Event $event)
 {
     $this->Auth->autoRedirect = FALSE;
     parent::beforeFilter($event);
     $this->viewBuilder()->layout('custom');
     $this->Auth->allow(['index', 'changepassword']);
 }
开发者ID:Campustop,项目名称:devv2,代码行数:7,代码来源:ForgotpasswordController.php

示例10: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     $this->Auth->allow(['index', 'add', 'edit', 'delete']);
     $this->loadModel('AdminRights');
     $this->loadModel('AdminRoleRights');
 }
开发者ID:franky0930,项目名称:MarketingConnex,代码行数:7,代码来源:AdminRolesController.php

示例11: beforeFilter

 public function beforeFilter(Event $event)
 {
     if ($this->request->param('action') != 'index') {
         $this->redirect(['action' => 'index']);
     }
     parent::beforeFilter($event);
 }
开发者ID:hunnybohara,项目名称:coin_bates,代码行数:7,代码来源:OptionsController.php

示例12: beforeFilter

 /**
  * Index method
  *
  * @return void
  */
 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     // Allow users to register and logout.
     // Allowing actions for not logged users
     $this->Auth->allow(['login', 'logout', 'forgotPassword', 'resetPassword', 'home']);
 }
开发者ID:neilan35,项目名称:betterwindow1,代码行数:12,代码来源:UsersController.php

示例13: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     if ($this->Auth->user('role') == 'superadmin') {
         $this->Auth->allow(['index', 'add', 'edit', 'delete']);
     }
 }
开发者ID:franky0930,项目名称:MarketingConnex,代码行数:7,代码来源:UserRolesController.php

示例14: beforeFilter

 public function beforeFilter(\Cake\Event\Event $event)
 {
     parent::beforeFilter($event);
     //        $this->Crud->listener('relatedModels')->relatedModels(['SocialAccounts'], 'index'); //why no worky
     //        $this->Crud->addListener('Crud.Search');
     $this->loadComponent('Stream');
 }
开发者ID:abf6ug,项目名称:statbro,代码行数:7,代码来源:FriendshipsController.php

示例15: beforeFilter

 public function beforeFilter(Event $event)
 {
     parent::beforeFilter($event);
     //Allow users to register and logout.
     $this->Auth->allow(['register', 'logout']);
     $this->set('role', $this->Auth->user('role'));
 }
开发者ID:akothman,项目名称:RecordManagement,代码行数:7,代码来源:UsersController.php


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