Пример #1
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     if (!User::systemUser()) {
         return false;
     }
     return parent::run();
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     $user = new User();
     $user->scenario = 'creation';
     $user->attributes = $this->input['admin'];
     $user->status = User::STATUS_ACTIVE;
     $superGroup = Group::find()->disableAccessCheck()->where(['system' => 'super_administrators'])->one();
     if (!$superGroup) {
         throw new Exception("Unable to find super_administrators group!");
     }
     $user->relationModels = [['parent_object_id' => $superGroup->primaryKey]];
     if ($user->save()) {
         return true;
     }
     foreach ($user->errors as $field => $errors) {
         $this->fieldErrors[$field] = implode('; ', $errors);
     }
     var_dump($this->fieldErrors);
     exit;
     return false;
 }