main/core/Controller/ResourceController.php
public function getAction($id, $embedded = 0)
    {
        /** @var ResourceNode $resourceNode */
        $resourceNode = $this->om->find(ResourceNode::class, $id);
        if (!$resourceNode) {
            throw new ResourceNotFoundException();
        }

        // gets the current user roles to check access restrictions
        $userRoles = $this->security->getRoles($this->tokenStorage->getToken());
        $accessErrors = $this->restrictionsManager->getErrors($resourceNode, $userRoles);

        if (empty($accessErrors) || $this->manager->isManager($resourceNode)) {
            try {
                $loaded = $this->manager->load($resourceNode, intval($embedded) ? true : false);
            } catch (ResourceNotFoundException $e) {
                return new JsonResponse(['resource_not_found'], 500);
            }

            return new JsonResponse(
                array_merge([
                    // append access restrictions to the loaded node
                    // if any to let know the manager that other user can not enter the resource
                    'accessErrors' => $accessErrors,
                ], $loaded)
            );
        }

        return new JsonResponse($accessErrors, 403);
    }
public function getAction($id, $embedded = 0)
    {
        /** @var ResourceNode $resourceNode */
        $resourceNode = $this->om->find(ResourceNode::class, $id);
        if (!$resourceNode) {
            throw new ResourceNotFoundException();
        }

        // gets the current user roles to check access restrictions
        $userRoles = $this->security->getRoles($this->tokenStorage->getToken());
        $accessErrors = $this->restrictionsManager->getErrors($resourceNode, $userRoles);

        if (empty($accessErrors) || $this->manager->isManager($resourceNode)) {
            try {
                $loaded = $this->manager->load($resourceNode, intval($embedded) ? true : false);
            } catch (ResourceNotFoundException $e) {
                return new JsonResponse(['resource_not_found'], 500);
            }

            return new JsonResponse(
                array_merge([
                    // append access restrictions to the loaded node
                    // if any to let know the manager that other user can not enter the resource
                    'accessErrors' => $accessErrors,
                ], $loaded)
            );
        }

        return new JsonResponse($accessErrors, 403);
    }
public function getAction ( $ id , $ embedded = 0 ) { /** @var ResourceNode $resourceNode */ $ resourceNode = $ this -> om -> find ( ResourceNode :: class , $ id ) ; if ( ! $ resourceNode ) { throw new ResourceNotFoundException ( ) ; } // gets the current user roles to check access restrictions $ userRoles = $ this -> security -> getRoles ( $ this -> tokenStorage -> getToken ( ) ) ; $ accessErrors = $ this -> restrictionsManager -> getErrors ( $ resourceNode , $ userRoles ) ; if ( empty ( $ accessErrors ) || $ this -> manager -> isManager ( $ resourceNode ) ) { try { $ loaded = $ this -> manager -> load ( $ resourceNode , intval ( $ embedded ) ? true : false ) ; } catch ( ResourceNotFoundException $ e ) { return new JsonResponse ( [ 'resource_not_found' ] , 500 ) ; } return new JsonResponse ( array_merge ( [ // append access restrictions to the loaded node // if any to let know the manager that other user can not enter the resource 'accessErrors' => $ accessErrors , ] , $ loaded ) ) ; } return new JsonResponse ( $ accessErrors , 403 ) ; }
Gets a resource.

@EXT\Route("/{id}", name="claro_resource_load_short")
@EXT\Route("/{type}/{id}", name="claro_resource_load")
@EXT\Route("/{type}/{id}/embedded/{embedded}", name="claro_resource_load_embedded")
@EXT\Method("GET")

@param int|string $id       - the id of the target node (we don't use ParamConverter to support ID and UUID)
@param int        $embedded

@return JsonResponse

@throws ResourceNotFoundException
Gets a resource .