'viewAccess' => [ 'class' => CmsAccessControl::className(), 'only' => ['view'], 'rules' => [ [ 'allow' => true, 'matchCallback' => function($rule, $action) { if ($this->model->cmsContent && $this->model->cmsContent->access_check_element == 'Y') { //Если такая привилегия заведена, нужно ее проверять. if ($permission = \Yii::$app->authManager->getPermission($this->model->permissionName)) { if (!\Yii::$app->user->can($permission->name)) { return false; } } } return true;
'only' => ['view'], 'rules' => [ [ 'allow' => true, 'matchCallback' => function($rule, $action) { if ($this->model->cmsContent && $this->model->cmsContent->access_check_element == 'Y') { //Если такая привилегия заведена, нужно ее проверять. if ($permission = \Yii::$app->authManager->getPermission($this->model->permissionName)) { if (!\Yii::$app->user->can($permission->name)) { return false; } }
/** * @param Action $action the action to be performed * @return bool whether the rule should be applied */ protected function matchCustom($action) { return empty($this->matchCallback) || call_user_func($this->matchCallback, $this, $action); } }
{ if ($this->matchAction($action) && $this->matchRole($user) && $this->matchIP($request->getUserIP()) && $this->matchVerb($request->getMethod()) && $this->matchController($action->controller) && $this->matchCustom($action) ) { return $this->allow ? true : false; } return null; }
public function beforeAction($action) { $user = $this->user; $request = Yii::$app->getRequest(); /* @var $rule AccessRule */ foreach ($this->rules as $rule) { if ($allow = $rule->allows($action, $user, $request)) { return true; } elseif ($allow === false) { if (isset($rule->denyCallback)) { call_user_func($rule->denyCallback, $rule, $action); } elseif ($this->denyCallback !== null) { call_user_func($this->denyCallback, $rule, $action);
public function beforeFilter($event) { if (!$this->isActive($event->action)) { return; } $event->isValid = $this->beforeAction($event->action); if ($event->isValid) { // call afterFilter only if beforeFilter succeeds // beforeFilter and afterFilter should be properly nested $this->owner->on(Controller::EVENT_AFTER_ACTION, [$this, 'afterFilter'], null, false); } else { $event->handled = true;
$event->sender = $this; } $event->handled = false; $event->name = $name; foreach ($this->_events[$name] as $handler) { $event->data = $handler[1]; call_user_func($handler[0], $event); // stop further handling if the event is handled if ($event->handled) { return; } } }
* @param Action $action the action to be executed. * @return bool whether the action should continue to run. */ public function beforeAction($action) { $event = new ActionEvent($action); $this->trigger(self::EVENT_BEFORE_ACTION, $event); return $event->isValid; } /** * This method is invoked right after an action is executed. *
/** * @inheritdoc */ public function beforeAction($action) { if (parent::beforeAction($action)) { if ($this->enableCsrfValidation && Yii::$app->getErrorHandler()->exception === null && !Yii::$app->getRequest()->validateCsrfToken()) { throw new BadRequestHttpException(Yii::t('yii', 'Unable to verify your data submission.')); } return true; }
break; } } $result = null; if ($runAction && $this->beforeAction($action)) { // run the action $result = $action->runWithParams($params); $result = $this->afterAction($action, $result); // call afterAction on modules
$parts = $this->createController($route); if (is_array($parts)) { /* @var $controller Controller */ list($controller, $actionID) = $parts; $oldController = Yii::$app->controller; Yii::$app->controller = $controller; $result = $controller->runAction($actionID, $params); if ($oldController !== null) { Yii::$app->controller = $oldController; } return $result; }
$params = $this->catchAll; unset($params[0]); } try { Yii::trace("Route requested: '$route'", __METHOD__); $this->requestedRoute = $route; $result = $this->runAction($route, $params); if ($result instanceof Response) { return $result; } $response = $this->getResponse(); if ($result !== null) {
{ try { $this->state = self::STATE_BEFORE_REQUEST; $this->trigger(self::EVENT_BEFORE_REQUEST); $this->state = self::STATE_HANDLING_REQUEST; $response = $this->handleRequest($this->getRequest()); $this->state = self::STATE_AFTER_REQUEST; $this->trigger(self::EVENT_AFTER_REQUEST); $this->state = self::STATE_SENDING_RESPONSE; $response->send();
} $config = (array)require $configFile; \Yii::endProfile('Load config app'); $application = new yii\web\Application($config); $application->run();
if (ENV === 'dev') { defined('YII_DEBUG') or define('YII_DEBUG', true); defined('YII_ENV') or define('YII_ENV', 'dev'); } define("ROOT_DIR", dirname(dirname(__DIR__))); require(ROOT_DIR . '/vendor/skeeks/cms/app-web.php');
$_GET = [ 'id' => '19', 'code' => 'vyiezd-vracha-na-dom', ];