コード例 #1
0
ファイル: ResultTest.php プロジェクト: reliv/rcm-user
 /**
  * testConstruct
  *
  * @return void
  */
 public function testConstruct()
 {
     $result = new Result();
     $result->__construct(null, Result::CODE_SUCCESS, ['Test Message']);
 }
コード例 #2
0
 /**
  * fetchByParentRoleId
  *
  * @param mixed $parentRoleId the parent id
  *
  * @return Result
  */
 public function fetchByParentRoleId($parentRoleId)
 {
     $roles = $this->getEntityManager()->getRepository($this->getEntityClass())->findBy(['parentRoleId' => $parentRoleId]);
     $result = new Result($roles);
     if (empty($roles)) {
         $result->setMessage('No roles found,');
     }
     return $result;
 }
コード例 #3
0
 /**
  * delete
  *
  * @param User  $user  user
  * @param array $roles roles
  *
  * @return Result
  */
 public function delete(User $user, $roles = [])
 {
     $failed = [];
     $result = new Result($failed, Result::CODE_SUCCESS);
     foreach ($roles as $key => $roleId) {
         $removeResult = $this->remove($user, $roleId);
         if (!$removeResult->isSuccess()) {
             $failed[] = $roleId;
             $result->setCode(Result::CODE_FAIL);
             $result->setMessage("Failed to remove role {$roleId} with error: " . $removeResult->getMessage());
             $result->setData($failed);
         } else {
             $result->setMessage("Removed role {$roleId}");
         }
     }
     return $result;
 }