本文整理汇总了PHP中ControllerBase::beforeAction方法的典型用法代码示例。如果您正苦于以下问题:PHP ControllerBase::beforeAction方法的具体用法?PHP ControllerBase::beforeAction怎么用?PHP ControllerBase::beforeAction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ControllerBase
的用法示例。
在下文中一共展示了ControllerBase::beforeAction方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: beforeAction
/**
* Register any values that needed on beforeAction
* @param CAction $action action
* @return boolean whether the action is allowed ?
*/
public function beforeAction($action)
{
if ($action->controller->route !== Yii::app()->errorHandler->errorAction) {
$userWeb = UserWeb::instance();
if (isset($_GET['lang'])) {
$cookie = new CHttpCookie('lang', $_GET['lang']);
$cookie->expire = time() + 60 * 60 * 24 * 180;
Yii::app()->request->cookies['lang'] = $cookie;
$this->redirect(array("{$this->route}"));
}
$this->language = Yii::app()->request->cookies->contains('lang') ? Yii::app()->request->cookies['lang']->value : 'id';
$this->renderJS(['baseURL' => Yii::app()->baseUrl], ['lang' => $this->language]);
$isIndonesian = $this->language === 'id';
if (!$userWeb->isGuest) {
$user = $userWeb->user();
if (isset($user) && !$user->verifiedUser) {
$this->data['notifications']['verifyEmail'] = ['URL' => $this->createUrl('/site/verify'), 'title' => 'Pastikan email kamu terverifikasi', 'message' => "Silahkan periksa email anda untuk verifikasi", 'labelButton' => 'Verifikasi Ulang'];
}
}
}
return parent::beforeAction($action);
}