/** @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]), []];
         }
     }
 }
 /**
  * Updated items children.
  */
 protected function updateChildren()
 {
     $children = $this->manager->getChildren($this->item->name);
     $childrenNames = array_keys($children);
     if (is_array($this->children)) {
         // remove children that
         foreach (array_diff($childrenNames, $this->children) as $item) {
             $this->manager->removeChild($this->item, $children[$item]);
         }
         // add new children
         foreach (array_diff($this->children, $childrenNames) as $item) {
             $this->manager->addChild($this->item, $this->manager->getItem($item));
         }
     } else {
         $this->manager->removeChildren($this->item);
     }
 }
 /** @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 matacms/matacms-user extension is installed, copy admin list from there
         if ($this->checkUserModuleInstalled($app)) {
             $app->getModule('rbac')->admins = $app->getModule('user')->admins;
         }
     }
     Event::on(ActiveField::className(), ActiveField::EVENT_INIT_DONE, function (MessageEvent $event) {
         $event->getMessage()->attachBehavior('roleAssignments', new RoleAssignmentActiveFormBehavior());
     });
     Event::on(AdminController::class, Controller::EVENT_MODEL_UPDATED, function (\matacms\base\MessageEvent $event) {
         $this->processSave($event->getMessage());
     });
     Event::on(AdminController::class, Controller::EVENT_MODEL_CREATED, function (\matacms\base\MessageEvent $event) {
         $this->processSave($event->getMessage());
     });
 }
 /**
  * Returns all available auth items to be attached to user.
  * @return array
  */
 public function getAvailableItems()
 {
     return ArrayHelper::map($this->manager->getItems(), 'name', function ($item) {
         return empty($item->description) ? $item->name : $item->name . ' (' . $item->description . ')';
     });
 }