original_string: protected function addInheritedAdmin()
      {
          if (empty($this->module->adminId)) {
              $this->type = self::TYPE_WARNING;
              return Yii::t('podium/flash', 'No administrator privileges have been set!');
          }
          try {
              $identity = Podium::getInstance()->user->identityClass;
              $inheritedUser = $identity::findIdentity($this->module->adminId);
              if (!$inheritedUser) {
                  throw new Exception('Can not find administrator account!');
              }
              $userNameField = $this->module->userNameField;
              if ($userNameField !== null && empty($inheritedUser->$userNameField)) {
                  throw new Exception('Can not find administrator username!');
              }
          } catch (Exception $e) {
              return $this->returnWarning(Yii::t('podium/flash', 'Cannot find inherited user of given ID. No administrator privileges have been set.'));
          }
  
          $transaction = $this->db->beginTransaction();
          try {
              $admin = new User();
              $admin->setScenario('installation');
              $admin->setAttributes([
                  'inherited_id' => $this->module->adminId,
                  'username' => $userNameField ? $inheritedUser->$userNameField : self::DEFAULT_USERNAME,
                  'status' => User::STATUS_ACTIVE,
                  'role' => User::ROLE_ADMIN,
              ], false);
              if (!$admin->save()) {
                  throw new Exception(VarDumper::dumpAsString($admin->errors));
              }
              if (!$this->authManager->assign($this->authManager->getRole(Rbac::ROLE_ADMIN), $admin->id)) {
                  throw new Exception('Error during Administrator privileges setting!');
              }
              $transaction->commit();
              return $this->returnSuccess(Yii::t('podium/flash', 'Administrator privileges have been set for the user of ID {id}.', [
                  'id' => $this->module->adminId
              ]));
          } catch (Exception $e) {
              $transaction->rollBack();
              return $this->returnError($e->getMessage(), __METHOD__,
                  Yii::t('podium/flash', 'Error during account creating')
              );
          }
      }
code: protected function addInheritedAdmin()
      {
          if (empty($this->module->adminId)) {
              $this->type = self::TYPE_WARNING;
              return Yii::t('podium/flash', 'No administrator privileges have been set!');
          }
          try {
              $identity = Podium::getInstance()->user->identityClass;
              $inheritedUser = $identity::findIdentity($this->module->adminId);
              if (!$inheritedUser) {
                  throw new Exception('Can not find administrator account!');
              }
              $userNameField = $this->module->userNameField;
              if ($userNameField !== null && empty($inheritedUser->$userNameField)) {
                  throw new Exception('Can not find administrator username!');
              }
          } catch (Exception $e) {
              return $this->returnWarning(Yii::t('podium/flash', 'Cannot find inherited user of given ID. No administrator privileges have been set.'));
          }
  
          $transaction = $this->db->beginTransaction();
          try {
              $admin = new User();
              $admin->setScenario('installation');
              $admin->setAttributes([
                  'inherited_id' => $this->module->adminId,
                  'username' => $userNameField ? $inheritedUser->$userNameField : self::DEFAULT_USERNAME,
                  'status' => User::STATUS_ACTIVE,
                  'role' => User::ROLE_ADMIN,
              ], false);
              if (!$admin->save()) {
                  throw new Exception(VarDumper::dumpAsString($admin->errors));
              }
              if (!$this->authManager->assign($this->authManager->getRole(Rbac::ROLE_ADMIN), $admin->id)) {
                  throw new Exception('Error during Administrator privileges setting!');
              }
              $transaction->commit();
              return $this->returnSuccess(Yii::t('podium/flash', 'Administrator privileges have been set for the user of ID {id}.', [
                  'id' => $this->module->adminId
              ]));
          } catch (Exception $e) {
              $transaction->rollBack();
              return $this->returnError($e->getMessage(), __METHOD__,
                  Yii::t('podium/flash', 'Error during account creating')
              );
          }
      }
code_tokens: protected function addInheritedAdmin ( ) { if ( empty ( $ this -> module -> adminId ) ) { $ this -> type = self :: TYPE_WARNING ; return Yii :: t ( 'podium/flash' , 'No administrator privileges have been set!' ) ; } try { $ identity = Podium :: getInstance ( ) -> user -> identityClass ; $ inheritedUser = $ identity :: findIdentity ( $ this -> module -> adminId ) ; if ( ! $ inheritedUser ) { throw new Exception ( 'Can not find administrator account!' ) ; } $ userNameField = $ this -> module -> userNameField ; if ( $ userNameField !== null && empty ( $ inheritedUser -> $ userNameField ) ) { throw new Exception ( 'Can not find administrator username!' ) ; } } catch ( Exception $ e ) { return $ this -> returnWarning ( Yii :: t ( 'podium/flash' , 'Cannot find inherited user of given ID. No administrator privileges have been set.' ) ) ; } $ transaction = $ this -> db -> beginTransaction ( ) ; try { $ admin = new User ( ) ; $ admin -> setScenario ( 'installation' ) ; $ admin -> setAttributes ( [ 'inherited_id' => $ this -> module -> adminId , 'username' => $ userNameField ? $ inheritedUser -> $ userNameField : self :: DEFAULT_USERNAME , 'status' => User :: STATUS_ACTIVE , 'role' => User :: ROLE_ADMIN , ] , false ) ; if ( ! $ admin -> save ( ) ) { throw new Exception ( VarDumper :: dumpAsString ( $ admin -> errors ) ) ; } if ( ! $ this -> authManager -> assign ( $ this -> authManager -> getRole ( Rbac :: ROLE_ADMIN ) , $ admin -> id ) ) { throw new Exception ( 'Error during Administrator privileges setting!' ) ; } $ transaction -> commit ( ) ; return $ this -> returnSuccess ( Yii :: t ( 'podium/flash' , 'Administrator privileges have been set for the user of ID {id}.' , [ 'id' => $ this -> module -> adminId ] ) ) ; } catch ( Exception $ e ) { $ transaction -> rollBack ( ) ; return $ this -> returnError ( $ e -> getMessage ( ) , __METHOD__ , Yii :: t ( 'podium/flash' , 'Error during account creating' ) ) ; } }
docstring: Adds Administrator account for inherited User Identity.
  @return string result message.
  @since 0.2
docstring_tokens: Adds Administrator account for inherited User Identity .