protected function isAllowed($resource, $privilege) { if (null === $this->allowedService) { $this->allowedService = $this->getServiceLocator()->get(Authorize::class); } return $this->allowedService->isAllowed($resource, $privilege); }
/** * @param mixed $resource * @param mixed|null $privilege * @return bool */ public function __invoke($resource, $privilege = null) { return $this->authorizeService->isAllowed($resource, $privilege); }
/** * @param \BjyAuthorize\Service\Authorize $authorizeService * @param \stdClass $entity */ public function it_should_use_classname_if_entity_is_no_ResourceInterface($authorizeService, $entity) { $authorizeService->isAllowed(Argument::cetera())->willReturn(true); $this->mockListenerFactory($authorizeService->getWrappedObject()); $className = get_class($entity->getWrappedObject()); $permission = 'permission'; $this->isAllowed($entity, $permission); $authorizeService->isAllowed($className, $permission)->shouldBeCalled(); }