Exemplo n.º 1
0
 /**
  * testToString
  *
  * @return void
  */
 public function testToString()
 {
     $aclRole = new AclRole();
     $aclRole->setRoleId('role');
     $this->assertEquals('role', $aclRole->__toString(), 'toString should return role id.');
 }
Exemplo n.º 2
0
 protected function addUsers($username, $password, $fullname, $email)
 {
     $sm = $this->getServiceLocator();
     /** @var \RcmUser\Service\RcmUserService $userService */
     $userService = $sm->get('RcmUser\\Service\\RcmUserService');
     /** @var \RcmUser\User\Service\UserRoleService $userRoleService */
     $userRoleService = $sm->get('RcmUser\\User\\Service\\UserRoleService');
     /** @var \RcmUser\Acl\Service\AclDataService $aclDataService */
     $aclDataService = $sm->get('RcmUser\\Acl\\AclDataService');
     $user = new User();
     $user->setUsername($username);
     $user->setPassword($password);
     $user->setEmail($email);
     $user->setName($fullname);
     $user->setState('enabled');
     $response = $userService->createUser($user);
     if (!$response->isSuccess()) {
         throw new \Exception(implode("<br />", $response->getMessages()));
     }
     $user = $response->getData();
     $suRoleIdResponse = $aclDataService->getSuperAdminRoleId();
     $suRoleId = $suRoleIdResponse->getData();
     $suRole = new AclRole();
     $suRole->setRoleId($suRoleId);
     $suRole->setDescription('Super Admin Role');
     $response = $aclDataService->createRole($suRole);
     if (!$response->isSuccess()) {
         throw new \Exception(implode("<br />", $response->getMessages()));
     }
     $guestRoleIdResponse = $aclDataService->getGuestRoleId();
     $guestRoleId = $guestRoleIdResponse->getData();
     $guestRole = new AclRole();
     $guestRole->setRoleId($guestRoleId);
     $guestRole->setDescription('Default Guest');
     $response = $aclDataService->createRole($guestRole);
     if (!$response->isSuccess()) {
         throw new \Exception(implode("<br />", $response->getMessages()));
     }
     $response = $userRoleService->addRole($user, $suRoleId);
     if (!$response->isSuccess()) {
         throw new \Exception(implode("<br />", $response->getMessages()));
     }
 }
Exemplo n.º 3
0
 /**
  * delete
  *
  * @param string $id id
  *
  * @return mixed|JsonModel
  */
 public function delete($id)
 {
     // ACCESS CHECK
     if (!$this->isAllowed(RcmUserAclResourceProvider::RESOURCE_ID_ACL, 'delete')) {
         return $this->getNotAllowedResponse();
     }
     $aclDataService = $this->getServiceLocator()->get('RcmUser\\Acl\\AclDataService');
     try {
         $aclRole = new AclRole();
         $aclRole->setRoleId((string) $id);
         $result = $aclDataService->deleteRole($aclRole);
     } catch (\Exception $e) {
         return $this->getExceptionResponse($e);
     }
     return $this->getJsonResponse($result);
 }