本文整理汇总了PHP中Cake\Controller\Controller::beforeRender方法的典型用法代码示例。如果您正苦于以下问题:PHP Controller::beforeRender方法的具体用法?PHP Controller::beforeRender怎么用?PHP Controller::beforeRender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Controller\Controller
的用法示例。
在下文中一共展示了Controller::beforeRender方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
// if (!empty($this->request->params['prefix']) && $this->request->params['prefix'] === 'admin') {
// $this->layout = 'dashboard';
// }
}
示例2: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
if ($this->request->is('ajax')) {
$this->layout = 'ajax';
}
}
示例3: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
if ($this->Auth->user()) {
$this->loadModel('Users');
$user = $this->Users->get($this->Auth->user()['id']);
$user->last_access = Time::now();
$this->Users->save($user);
/*
$limitOnline = new Time('10 minutes ago');
$onlineUsers = $this->Users->find()->where(['last_access >=' => $limitOnline, 'id <> '=>$this->Auth->user()['id']]);
$nonOnlineUsers = $this->Users->find()->where(['last_access <' => $limitOnline, 'id <> '=>$this->Auth->user()['id']]);
$newMessagesUsers = $this->Users->find()->select([
'Users.id','Users.login',
])->join([
'Chat' => [
'table' => 'chat',
'type' => 'INNER',
'conditions' => 'Chat.to_user_id = Users.id ',
]
])->where([
'Chat.created > Users.last_access',
'Users.id' => $this->Auth->user()['id']
]);
*/
}
/*
$this->set('onlineUsers', $onlineUsers);
$this->set('nonOnlineUsers', $nonOnlineUsers);
$this->set('newMessagesUsers', $newMessagesUsers);
*/
}
示例4: beforeRender
/**
* @param \Cake\Event\Event $event
* @return \Cake\Network\Response|null|void
*/
public function beforeRender(Event $event)
{
parent::beforeRender($event);
// Automatically shim $this->request->data = $this->Model->find() etc which used to be of type array
if (!empty($this->request->data) && $this->request->data instanceof Entity) {
$this->request->data = $this->request->data->toArray();
}
}
示例5: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->set('user', !is_null($this->Auth->user('id')) ? $this->Auth->user() : false);
if (!array_key_exists('_serialize', $this->viewVars) && in_array($this->response->type(), ['application/json', 'application/xml'])) {
$this->set('_serialize', true);
}
}
示例6: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
//ALLOW CONTROLLER ACTIONS
$this->Auth->allow('load_pages', 'home', 'article_view', 'rss', 'categories', 'contact', 'captcha_image');
$this->loadModel('Navigation');
$this->set('main_navigation', $main_navigation = $this->Navigation->find('all', array('order' => 'position ASC')));
$this->loadModel('Sidebar');
$this->set('main_sidebar', $main_sidebar = $this->Sidebar->find('all', array('order' => 'position ASC')));
$this->loadModel('Categories');
$this->set('sidebar_categories', $sidebar_categories = $this->Categories->find('all', array('order' => 'title ASC')));
}
示例7: beforeRender
/**
*
* @param Event $event
*/
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->Cookie->config(['expires' => '+10 days', 'path' => '/']);
$this->current_lang = 'en_US';
if (in_array($this->Cookie->read('lang'), array_keys(Configure::read('supported_lang')))) {
I18n::locale($this->Cookie->read('lang'));
$this->current_lang = $this->Cookie->read('lang');
}
$this->set('current_lang', $this->current_lang);
/**
*
* initialize the Google Client to verify the google Incomeing Stream
*/
$client = new \Google_Client();
$client->setClientId(Configure::read('GPLUS.client_id'));
$client->setClientSecret(Configure::read('gplus.secret'));
$client->setRedirectUri(Router::url(['controller' => 'users', 'action' => 'gpluslogin', '_full' => true]));
$client->setScopes('email');
$this->set('isFrontPage', $this->isFrontPage);
$this->set('current_user', $this->current_user);
$this->set('isUserLoggedIn', $this->isUserLoggedIn);
}
示例8: beforeRender
/**
* Configure the Helper and do automatic render setup if needed
*
* @param Event $event
*/
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->helpers['CrudViews.Crud'] = ['_CrudData' => $this->_CrudData, 'actions' => ['_ModelActions' => $this->_ModelActions, '_AssociationActions' => $this->_AssociationActions, '_RecordActions' => $this->_RecordActions]];
}
示例9: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
// Handling the breadcrumb
$this->set('breadcrumb', $this->breadcrumb);
$this->getView()->theme = 'AppUi';
}
示例10: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->set('breadcrumbs', $this->breadcrumbs);
$this->set('showBreadcrumb', $this->showBreadcrumb);
}
示例11: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
if ($this->request->query('is_dialog')) {
//TODO: convert popup dialog to a plugin
$this->viewBuilder()->layout('admin_popup');
}
}
示例12: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->layout = 'admin';
}
示例13: beforeRender
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$this->set('imageFields', $this->imageFields);
$this->handleAjaxFormRequest();
$this->set('titleLayout', $this->titleLayout);
}
示例14: beforeRender
/**
* beforeRender hook method.
*
* @param Event $event The beforeRender event that was fired.
*
* @return void
*/
public function beforeRender(Event $event)
{
parent::beforeRender($event);
if ($this->components()->has('Auth')) {
$builder = $this->viewBuilder();
$builder->helpers(['Acl' => $this->Auth->config('authorize')['Acl.Actions']]);
}
}
示例15: beforeRender
/**
* Before render callback.
*
* @param \Cake\Event\Event $event The beforeRender event.
* @return void
*/
public function beforeRender(Event $event)
{
parent::beforeRender($event);
$isRest = in_array($this->response->type(), ['application/json', 'application/xml']);
if (!array_key_exists('_serialize', $this->viewVars) && $isRest) {
$this->set('_serialize', true);
}
}