예제 #1
0
 /**
  * Checks link access with rbac AuthItem.
  * @param string $href url.
  * @return boolean whether link is accessable.
  */
 public static function checkHrefAccess($href)
 {
     if (!($rule = UrlHelper::rule($href))) {
         return true;
     }
     return AuthItem::checkAccess($rule);
 }
 public static function afterActionModelAccess($event)
 {
     /**
      * @var Controller $controller
      */
     $model = $event->sender;
     $controller = Yii::$app->controller;
     $permissionName = AuthItem::createPermissionName([$controller->module->id, $controller->id, $controller->action->id]);
     if (!AuthItem::checkAccess($permissionName, false, compact('model'))) {
         throw new HttpException(403, Yii::t('modules/rbac', 'access_denied'));
     }
 }