示例#1
0
 /** @inheritdoc */
 protected function validateValue($value)
 {
     if (!is_array($value)) {
         return [\Yii::t('rbac', 'Invalid value'), []];
     }
     foreach ($value as $val) {
         if ($this->manager->getItem($val) == null) {
             return [\Yii::t('rbac', 'There is neither role nor permission with name "{0}"', [$val]), []];
         }
     }
 }
示例#2
0
 /** @inheritdoc */
 public function bootstrap($app)
 {
     // register translations
     $app->get('i18n')->translations['rbac*'] = ['class' => 'yii\\i18n\\PhpMessageSource', 'basePath' => __DIR__ . '/messages'];
     if ($this->checkRbacModuleInstalled($app)) {
         // register auth manager
         if (!$this->checkAuthManagerConfigured($app)) {
             $app->set('authManager', ['class' => DbManager::className()]);
         }
         // if bmprbac/user extension is installed, copy admin list from there
         if ($this->checkUserModuleInstalled($app)) {
             $app->getModule('rbac')->admins = $app->getModule('user')->admins;
         }
     }
 }