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

        // TODO : not pretty, but might want on some case to download files instead ?
        // TODO : find a way to do it in the link plugin
        if ('shortcut' === $resourceNode->getResourceType()->getName()) {
            $shortcut = $this->manager->getResourceFromNode($resourceNode);
            $resourceNode = $shortcut->getTarget();
        }

        // do a minimal security check to redirect user which are not authenticated if needed.
        if (empty($currentUser) && 0 >= $this->rightsRepo->findMaximumRights([], $resourceNode)) {
            // user is not authenticated and the current node is not opened to anonymous
            throw new AccessDeniedException();
        }

        return [
            'resourceNode' => $resourceNode,
        ];
    }
public function showAction($id, User $currentUser = null)
    {
        /** @var ResourceNode $resourceNode */
        $resourceNode = $this->om->find(ResourceNode::class, $id);
        if (!$resourceNode) {
            throw new ResourceNotFoundException();
        }

        // TODO : not pretty, but might want on some case to download files instead ?
        // TODO : find a way to do it in the link plugin
        if ('shortcut' === $resourceNode->getResourceType()->getName()) {
            $shortcut = $this->manager->getResourceFromNode($resourceNode);
            $resourceNode = $shortcut->getTarget();
        }

        // do a minimal security check to redirect user which are not authenticated if needed.
        if (empty($currentUser) && 0 >= $this->rightsRepo->findMaximumRights([], $resourceNode)) {
            // user is not authenticated and the current node is not opened to anonymous
            throw new AccessDeniedException();
        }

        return [
            'resourceNode' => $resourceNode,
        ];
    }
public function showAction ( $ id , User $ currentUser = null ) { /** @var ResourceNode $resourceNode */ $ resourceNode = $ this -> om -> find ( ResourceNode :: class , $ id ) ; if ( ! $ resourceNode ) { throw new ResourceNotFoundException ( ) ; } // TODO : not pretty, but might want on some case to download files instead ? // TODO : find a way to do it in the link plugin if ( 'shortcut' === $ resourceNode -> getResourceType ( ) -> getName ( ) ) { $ shortcut = $ this -> manager -> getResourceFromNode ( $ resourceNode ) ; $ resourceNode = $ shortcut -> getTarget ( ) ; } // do a minimal security check to redirect user which are not authenticated if needed. if ( empty ( $ currentUser ) && 0 >= $ this -> rightsRepo -> findMaximumRights ( [ ] , $ resourceNode ) ) { // user is not authenticated and the current node is not opened to anonymous throw new AccessDeniedException ( ) ; } return [ 'resourceNode' => $ resourceNode , ] ; }
Renders a resource application.

@EXT\Route("/show/{id}", name="claro_resource_show_short")
@EXT\Route("/show/{type}/{id}", name="claro_resource_show")
@EXT\Method("GET")
@EXT\ParamConverter("currentUser", converter="current_user", options={"allowAnonymous"=true})
@EXT\Template()

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

@return array

@throws ResourceNotFoundException
Renders a resource application .