本文整理汇总了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();
}
示例2: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->loadModel('Financialquarters');
$this->loadModel('PartnerManagers');
$this->layout = 'admin';
}
示例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);
}
示例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);
}
}
}
示例5: beforeFilter
public function beforeFilter(\Cake\Event\Event $event)
{
parent::beforeFilter($event);
$this->adminOnly(['action' => 'index']);
$pageLimit = 10;
$this->set('pageLimit', $pageLimit);
}
示例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;
}
}
示例7: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->layout = 'admin';
$this->loadModel('PartnerMailinglists');
$this->loadModel('PartnerMailinglistSegmentRules');
}
示例8: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
// Allow users to register and logout.
$this->Auth->allow(['index']);
//$this->loadComponent('Socialmedia');
}
示例9: beforeFilter
public function beforeFilter(Event $event)
{
$this->Auth->autoRedirect = FALSE;
parent::beforeFilter($event);
$this->viewBuilder()->layout('custom');
$this->Auth->allow(['index', 'changepassword']);
}
示例10: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->Auth->allow(['index', 'add', 'edit', 'delete']);
$this->loadModel('AdminRights');
$this->loadModel('AdminRoleRights');
}
示例11: beforeFilter
public function beforeFilter(Event $event)
{
if ($this->request->param('action') != 'index') {
$this->redirect(['action' => 'index']);
}
parent::beforeFilter($event);
}
示例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']);
}
示例13: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
if ($this->Auth->user('role') == 'superadmin') {
$this->Auth->allow(['index', 'add', 'edit', 'delete']);
}
}
示例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');
}
示例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'));
}