/var/www/vhosts/nabawater/frontend/components
NameSizeModeActions
CActiveField.php97460644editdlrm
CActiveForm.php24460644editdlrm
CController.php44060644editdlrm
CmsDynamicRoute.php8510644editdlrm
Edit: /var/www/vhosts/nabawater/frontend/components/CController.php (4406B)
*/ class CController extends Controller { private $language; /** * CController constructor. * @param string $id * @param \yii\base\Module $module * @param array $config */ public function __construct($id, $module, array $config = array()) { parent::__construct($id, $module, $config); if (!Com::isSession(APP_LANGUAGE)) { Com::setSession(APP_LANGUAGE, Configuration::DEFAULT_LANG_CODE); } $language = Com::session(APP_LANGUAGE); $this->setLanguage((($language))); Yii::$app->timeZone = Configuration::get(Configuration::TIME_ZONE); } /** * @return array * @throws \yii\base\InvalidParamException */ public function behaviors() { return [ 'access' => [ 'class' => AccessControl::class, 'rules' => [ [ 'allow' => true, 'matchCallback' => function ($rule, $action) { $isGuest = Yii::$app->getUser()->getIsGuest(); return !($isGuest && ArrayHelper::isIn( $action->getUniqueId(), [ //'cart/index', 'user', 'user/index', 'user/loyalty', 'user-address/index', 'order/index', 'order/view', 'user/profile', 'user/address', 'user/orders', 'user/reviews', 'user/favourites', 'user/logout', 'order/details', 'user/refund-bottle', //'order/checkout', ] )); } ] ], ] ]; } /** * @param string $language */ public function setLanguage($language = null) { if ($language === null) { $language = Configuration::DEFAULT_LANG_CODE; } Yii::$app->language = $this->language = $language; } /** * @param $action * @return bool * @throws \yii\web\BadRequestHttpException */ public function beforeAction($action) { $actionId = $this->action->getUniqueId(); $actionId = explode('/', $actionId); $actionT = end($actionId); $controllerT = $actionId[0]; $actionT = implode(' ', explode('-', $actionT)); $controllerT = implode(' ', explode('-', $controllerT)); $this->view->title = ucfirst($actionT); if ($actionT === 'index') { $this->view->title = ucfirst($controllerT); } return parent::beforeAction($action); } /** * @param Model $model * @return array * @throws \yii\base\InvalidParamException */ protected function prepareErrors(Model $model) { $activeRecordErrors = $model->getErrors(); $errors = []; foreach ($activeRecordErrors as $attribute => $error) { $errors[Html::getInputId($model, $attribute)] = $error; } return $errors; } public function logout() { Com::successFlash('User logged out successfully'); return Yii::$app->getResponse()->redirect(Yii::$app->getHomeUrl()); } }