本文整理汇总了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']);
}
示例2: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->Auth->allow([]);
$this->localeSite();
$this->viewBuilder()->layout('default');
}
示例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');
}
示例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'));
}
示例5: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
if (!$this->request->is('post')) {
$this->loadComponent('Search.Prg');
}
}
示例6: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
if ($this->Auth->user()) {
$this->set('auth', $this->Auth->user());
}
}
示例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);
}
}
示例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());
}
示例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);
}
}
示例10: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$stats = NULL;
//$this->request->find('...');
$this->set('stats', $stats);
}
示例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']);
}
示例12: beforeFilter
public function beforeFilter(Event $event)
{
parent::beforeFilter($event);
$this->Auth->allow('*');
if ($this->Auth->user('id')) {
$this->viewBuilder()->layout('loggedin');
}
}
示例13: beforeFilter
public function beforeFilter(Event $event)
{
if ($this->Auth->user()) {
$this->current_user = $this->Auth->user();
$this->isUserLoggedIn = TRUE;
}
parent::beforeFilter($event);
}
示例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']);
});
}
}
示例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');
}
}