public function getRule(EventInterface $event) {
        $acl = $event->getAccessControl();

        $request = $event->getRequest();
        $publicKey = $request->getRoute()->get('publickey');
        $accessRuleId = $request->getRoute()->get('accessRuleId');

        $keyExists = $acl->publicKeyExists($publicKey);

        if (!$keyExists) {
            throw new RuntimeException('Public key not found', 404);
        }

        $accessRule = $acl->getAccessRule($publicKey, $accessRuleId);

        if (!$accessRule) {
            throw new RuntimeException('Access rule not found', 404);
        }

        $model = new AccessRuleModel();
        $model->setId($accessRule['id'])
              ->setUsers($accessRule['users']);

        if (isset($accessRule['group'])) {
            $model->setGroup($accessRule['group']);
        }

        if (isset($accessRule['resources'])) {
            $model->setResources($accessRule['resources']);
        }

        $event->getResponse()->setModel($model);
    }
public function getRule(EventInterface $event) {
        $acl = $event->getAccessControl();

        $request = $event->getRequest();
        $publicKey = $request->getRoute()->get('publickey');
        $accessRuleId = $request->getRoute()->get('accessRuleId');

        $keyExists = $acl->publicKeyExists($publicKey);

        if (!$keyExists) {
            throw new RuntimeException('Public key not found', 404);
        }

        $accessRule = $acl->getAccessRule($publicKey, $accessRuleId);

        if (!$accessRule) {
            throw new RuntimeException('Access rule not found', 404);
        }

        $model = new AccessRuleModel();
        $model->setId($accessRule['id'])
              ->setUsers($accessRule['users']);

        if (isset($accessRule['group'])) {
            $model->setGroup($accessRule['group']);
        }

        if (isset($accessRule['resources'])) {
            $model->setResources($accessRule['resources']);
        }

        $event->getResponse()->setModel($model);
    }
public function getRule ( EventInterface $ event ) { $ acl = $ event -> getAccessControl ( ) ; $ request = $ event -> getRequest ( ) ; $ publicKey = $ request -> getRoute ( ) -> get ( 'publickey' ) ; $ accessRuleId = $ request -> getRoute ( ) -> get ( 'accessRuleId' ) ; $ keyExists = $ acl -> publicKeyExists ( $ publicKey ) ; if ( ! $ keyExists ) { throw new RuntimeException ( 'Public key not found' , 404 ) ; } $ accessRule = $ acl -> getAccessRule ( $ publicKey , $ accessRuleId ) ; if ( ! $ accessRule ) { throw new RuntimeException ( 'Access rule not found' , 404 ) ; } $ model = new AccessRuleModel ( ) ; $ model -> setId ( $ accessRule [ 'id' ] ) -> setUsers ( $ accessRule [ 'users' ] ) ; if ( isset ( $ accessRule [ 'group' ] ) ) { $ model -> setGroup ( $ accessRule [ 'group' ] ) ; } if ( isset ( $ accessRule [ 'resources' ] ) ) { $ model -> setResources ( $ accessRule [ 'resources' ] ) ; } $ event -> getResponse ( ) -> setModel ( $ model ) ; }
Get an access control rule specified by ID

@param EventInterface $event The current event
Get an access control rule specified by ID