Ejemplo n.º 1
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 {
         $data = json_decode($this->getRequest()->getContent(), true);
         //$data = json_decode(urldecode($id), true);
         $aclRule = new AclRule();
         $aclRule->populate($data);
         $result = $aclDataService->deleteRule($aclRule);
     } catch (\Exception $e) {
         return $this->getExceptionResponse($e);
     }
     return $this->getJsonResponse($result);
 }
Ejemplo n.º 2
0
 public function testPopulate()
 {
     $aclRuleA = new AclRule();
     $aclRuleB = new AclRule();
     $data = ['rule' => 'allow', 'roleId' => 'somerole', 'resourceId' => 'someresource', 'privilege' => null, 'privileges' => ['someprivilege'], 'assertion' => 'someassertion'];
     $aclRuleA->populate($data);
     $arrayA = iterator_to_array($aclRuleA);
     $this->assertEquals($data, $arrayA, 'Populate failed.');
     $aclRuleB->populate($aclRuleA);
     $arrayB = iterator_to_array($aclRuleA);
     $this->assertEquals($arrayA, $arrayB, 'Populate failed.');
     try {
         $aclRuleB->populate('NOPE');
     } catch (RcmUserException $e) {
         $this->assertInstanceOf('\\RcmUser\\Exception\\RcmUserException', $e);
         return;
     }
     $this->fail("Expected exception not thrown");
 }