コード例 #1
0
 /**
  * When running a special action or a job an elevated user must be used in order to ensure the activities can
  * be processed properly.
  * @param boolean $createIfMissing creates system user if its missing
  * @return User $user
  * @throws NotFoundException if backend user can not be found and $createIfMissing is false
  */
 public static function getUserToRunAs($createIfMissing = true)
 {
     try {
         $user = User::getByUsername(static::USERNAME);
     } catch (NotFoundException $e) {
         if ($createIfMissing) {
             $user = InstallUtil::createBaseControlUserConfigUtilUserAccount();
         } else {
             throw new NotFoundException("Backend User: "******" was not found.");
         }
     }
     return $user;
 }