本文整理汇总了PHP中Component::beforeRender方法的典型用法代码示例。如果您正苦于以下问题:PHP Component::beforeRender方法的具体用法?PHP Component::beforeRender怎么用?PHP Component::beforeRender使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Component
的用法示例。
在下文中一共展示了Component::beforeRender方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeRender
public function beforeRender(Controller $controller)
{
if (!in_array($controller->request->params['action'], (array) $this->settings['on'])) {
return;
}
$this->Session->write('Feedback.RatingModels', $this->models);
foreach ($this->models as $modelClass => $model) {
$data = $this->readRatingCookie($modelClass);
$this->Session->write('Feedback.' . $modelClass . 'Ratings', $data);
}
if (!in_array('Feedback.Ratings', $controller->helpers)) {
$controller->helpers[] = 'Feedback.Ratings';
}
parent::beforeRender($controller);
}
示例2: beforeRender
public function beforeRender(Controller $controller)
{
parent::beforeRender($controller);
$controller->set('_pannel', array_merge($this->settings, $this->data));
}
示例3: beforeRender
public function beforeRender()
{
$this->controller->data->set('Lightbox', $this);
return parent::beforeRender();
}
示例4: beforeRender
/**
* Automatically create .installed file
* after controller executes requested action
*
* @param Controller $controller
*/
public function beforeRender(Controller $controller)
{
parent::beforeRender($controller);
$this->__afterModuleInstaller();
}
示例5: beforeRender
function beforeRender()
{
parent::beforeRender($this);
}
示例6: beforeRender
/**
* beforeRender callback
* レスポンスの描画を行います。
*
* @param Controller $controller
* @return void
*/
public function beforeRender(Controller $controller)
{
if ($this->isApiRequest($controller->request)) {
if (empty($this->_response)) {
$this->failure(ApiError::NOT_IMPLEMENTED, 501);
}
if ($this->logDb && Configure::read('debug') >= $this->logDb) {
$this->setResponse('dbLog', $this->_getDbLog());
}
$response = $this->getResponse();
$controller->response->statusCode($response['code']);
$controller->set(compact('response'));
$controller->set('_serialize', 'response');
if ($controller->viewClass === 'View') {
$controller->viewClass = 'Json';
}
}
return parent::beforeRender($controller);
}
示例7: beforeRender
/**
* Before render
*
* @param Controller $controller
* @return void
*/
public function beforeRender(Controller $controller)
{
parent::beforeRender($controller);
if (BcUtil::isAdminSystem()) {
$controller->set('contentsSettings', $this->settings['items']);
// パンくずをセット
array_unshift($controller->crumbs, array('name' => 'コンテンツ一覧', 'url' => array('plugin' => null, 'controller' => 'contents', 'action' => 'index')));
if ($controller->subMenuElements && !in_array('contents', $controller->subMenuElements)) {
array_unshift($controller->subMenuElements, 'contents');
} else {
$controller->subMenuElements = ['contents'];
}
if ($this->useForm && in_array($controller->request->action, [$this->editAction, 'admin_edit_alias']) && !empty($controller->request->data['Content'])) {
// フォームをセット
$this->settingForm($controller, $controller->request->data['Content']['site_id'], $controller->request->data['Content']['id']);
// フォームを読み込む為のイベントを設定
// 内部で useForm を参照できない為、ここに記述。
// フォームの設定しかできないイベントになってしまっている。
// TODO 改善要
App::uses('BcContentsEventListener', 'Event');
CakeEventManager::instance()->attach(new BcContentsEventListener());
}
} else {
// ビューキャッシュ設定
if (empty($controller->request->query['preview'])) {
// @deprecated 5.0.0 since 4.0.0
// CakePHP3では、ビューキャッシュは廃止となる為、別の方法に移行する
if ($this->useViewCache && !BcUtil::loginUser('admin') && !isConsole() && !empty($controller->request->params['Content'])) {
$controller->helpers[] = 'BcCache';
$controller->cacheAction = $controller->Content->getCacheTime($controller->request->params['Content']);
}
}
}
}
示例8: beforeRender
public function beforeRender(Controller $controller)
{
parent::beforeRender($controller);
if ($controller->request->params['prefix'] == 'front') {
$controller->request->params['prefix'] = '';
}
}
示例9: beforeRender
/**
* beforeRender callback
*
* Is called after the controller executes the requested action’s logic, but before the controller’s renders views and layout.
*
* - Save the filter, sort and pagination params to the session.
* - Can be later retrieved via FilterHelper::getBacklink($url)
*
* @param Controller $controller
*/
public function beforeRender(Controller $controller)
{
$filterOptions = array();
if ($this->slug) {
$filterOptions['slug'] = $this->slug;
}
if (!empty($this->activeSort)) {
foreach ($this->activeSort as $key => $val) {
if (isset($this->defaultSort) && $this->defaultSort['field'] !== $key || isset($this->defaultSort) && $this->defaultSort['field'] === $key && $this->defaultSort['dir'] !== $val) {
$filterOptions['s'] = $key;
$filterOptions['d'] = $val;
}
}
}
if (!empty($this->paginationParams) && isset($this->paginationParams['page']) && $this->paginationParams['page'] != 1) {
$filterOptions['p'] = $this->paginationParams['page'];
}
if ($this->activeLimit && $this->activeLimit !== $this->defaultLimit) {
$filterOptions['l'] = $this->activeLimit;
}
$path = 'FILTER_' . join('.', array($controller->request->params['plugin'], $controller->request->params['controller'], $controller->request->params['action']));
if (!empty($filterOptions)) {
$this->Session->write($path, $filterOptions);
} else {
$this->Session->delete($path);
}
parent::beforeRender($controller);
}