/** * Gets the resource if the current user is granted and if the resource exists. * * @param string $resourceId The resource id * @param string $grant The grant, by default is view * * @throws \Symfony\Component\Security\Core\Exception\AccessDeniedException * * @return Object */ protected function getResourceIfAllowed($resourceId, $grant = 'view') { $resource = $this->repository->find($resourceId, false); if (!$this->context->isGranted($grant, $resource)) { throw new AccessDeniedException(); } return $resource; }