Exemplo n.º 1
0
 /**
  * @param $action
  * @param $model
  * @param $key
  * @param $index
  * @return bool
  */
 public function checkAccess($action, $model, $key, $index)
 {
     $params = is_array($key) ? $key : ['id' => (string) $key];
     $params[0] = $this->controller ? $this->controller . '/' . $action : $action;
     if (!isset($this->_checkAccessCache[$params[0]])) {
         $operation = Rbac::routeToOperation(RouteNormalizer::normalizeRoute($params[0]));
         $this->_checkAccessCache[$params[0]] = Yii::$app->user->can($operation);
     }
     return $this->_checkAccessCache[$params[0]];
 }
Exemplo n.º 2
0
 /**
  * @param string|array $route
  * @return bool
  */
 protected function checkAccess($route)
 {
     if (is_array($route)) {
         $route = reset($route);
     }
     $operation = Rbac::routeToOperation(RouteNormalizer::normalizeRoute($route));
     return \Yii::$app->user->can($operation);
 }