main/core/API/Serializer/Resource/ResourceNodeSerializer.php
public function serialize(ResourceNode $resourceNode, array $options = [])
    {
        $serializedNode = [
            //also used for the export. It's not pretty.

            'autoId' => $resourceNode->getId(),
            'id' => $resourceNode->getUuid(),
            'name' => $resourceNode->getName(),
            'path' => $resourceNode->getAncestors(),
            'meta' => $this->serializeMeta($resourceNode, $options),
            'permissions' => $this->rightsManager->getCurrentPermissionArray($resourceNode),
            'poster' => $this->serializePoster($resourceNode),
            'thumbnail' => $this->serializeThumbnail($resourceNode),
            // TODO : it should not be available in minimal mode
            // for now I need it to compute simple access rights (for display)
            // we should compute simple access here to avoid exposing this big object
            'rights' => $this->rightsManager->getRights($resourceNode, $options),
        ];

        // TODO : it should not (I think) be available in minimal mode
        // for now I need it to compute rights
        if ($resourceNode->getWorkspace() && !in_array(Options::REFRESH_UUID, $options)) {
            $serializedNode['workspace'] = [ // TODO : use workspace serializer with minimal option
                'id' => $resourceNode->getWorkspace()->getUuid(),
                'autoId' => $resourceNode->getWorkspace()->getId(), // because open url does not work with uuid
                'name' => $resourceNode->getWorkspace()->getName(),
                'code' => $resourceNode->getWorkspace()->getCode(),
            ];
        }

        if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
            $serializedNode = array_merge($serializedNode, [
                'display' => $this->serializeDisplay($resourceNode),
                'restrictions' => $this->serializeRestrictions($resourceNode),
            ]);
        }

        //maybe don't remove me, it's used by the export system
        $parent = $resourceNode->getParent();

        if (!empty($parent)) {
            $serializedNode['parent'] = [
                'id' => $parent->getUuid(),
                'autoId' => $parent->getId(), // TODO : remove me
                'name' => $parent->getName(),
            ];
        }

        if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
            $serializedNode['comments'] = array_map(function (ResourceComment $comment) {
                return $this->serializer->serialize($comment);
            }, $resourceNode->getComments()->toArray());
        }

        $serializedNode = $this->decorate($resourceNode, $serializedNode, $options);

        return $serializedNode;
    }
public function serialize(ResourceNode $resourceNode, array $options = [])
    {
        $serializedNode = [
            //also used for the export. It's not pretty.

            'autoId' => $resourceNode->getId(),
            'id' => $resourceNode->getUuid(),
            'name' => $resourceNode->getName(),
            'path' => $resourceNode->getAncestors(),
            'meta' => $this->serializeMeta($resourceNode, $options),
            'permissions' => $this->rightsManager->getCurrentPermissionArray($resourceNode),
            'poster' => $this->serializePoster($resourceNode),
            'thumbnail' => $this->serializeThumbnail($resourceNode),
            // TODO : it should not be available in minimal mode
            // for now I need it to compute simple access rights (for display)
            // we should compute simple access here to avoid exposing this big object
            'rights' => $this->rightsManager->getRights($resourceNode, $options),
        ];

        // TODO : it should not (I think) be available in minimal mode
        // for now I need it to compute rights
        if ($resourceNode->getWorkspace() && !in_array(Options::REFRESH_UUID, $options)) {
            $serializedNode['workspace'] = [ // TODO : use workspace serializer with minimal option
                'id' => $resourceNode->getWorkspace()->getUuid(),
                'autoId' => $resourceNode->getWorkspace()->getId(), // because open url does not work with uuid
                'name' => $resourceNode->getWorkspace()->getName(),
                'code' => $resourceNode->getWorkspace()->getCode(),
            ];
        }

        if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
            $serializedNode = array_merge($serializedNode, [
                'display' => $this->serializeDisplay($resourceNode),
                'restrictions' => $this->serializeRestrictions($resourceNode),
            ]);
        }

        //maybe don't remove me, it's used by the export system
        $parent = $resourceNode->getParent();

        if (!empty($parent)) {
            $serializedNode['parent'] = [
                'id' => $parent->getUuid(),
                'autoId' => $parent->getId(), // TODO : remove me
                'name' => $parent->getName(),
            ];
        }

        if (!in_array(Options::SERIALIZE_MINIMAL, $options)) {
            $serializedNode['comments'] = array_map(function (ResourceComment $comment) {
                return $this->serializer->serialize($comment);
            }, $resourceNode->getComments()->toArray());
        }

        $serializedNode = $this->decorate($resourceNode, $serializedNode, $options);

        return $serializedNode;
    }
public function serialize ( ResourceNode $ resourceNode , array $ options = [ ] ) { $ serializedNode = [ //also used for the export. It's not pretty. 'autoId' => $ resourceNode -> getId ( ) , 'id' => $ resourceNode -> getUuid ( ) , 'name' => $ resourceNode -> getName ( ) , 'path' => $ resourceNode -> getAncestors ( ) , 'meta' => $ this -> serializeMeta ( $ resourceNode , $ options ) , 'permissions' => $ this -> rightsManager -> getCurrentPermissionArray ( $ resourceNode ) , 'poster' => $ this -> serializePoster ( $ resourceNode ) , 'thumbnail' => $ this -> serializeThumbnail ( $ resourceNode ) , // TODO : it should not be available in minimal mode // for now I need it to compute simple access rights (for display) // we should compute simple access here to avoid exposing this big object 'rights' => $ this -> rightsManager -> getRights ( $ resourceNode , $ options ) , ] ; // TODO : it should not (I think) be available in minimal mode // for now I need it to compute rights if ( $ resourceNode -> getWorkspace ( ) && ! in_array ( Options :: REFRESH_UUID , $ options ) ) { $ serializedNode [ 'workspace' ] = [ // TODO : use workspace serializer with minimal option 'id' => $ resourceNode -> getWorkspace ( ) -> getUuid ( ) , 'autoId' => $ resourceNode -> getWorkspace ( ) -> getId ( ) , // because open url does not work with uuid 'name' => $ resourceNode -> getWorkspace ( ) -> getName ( ) , 'code' => $ resourceNode -> getWorkspace ( ) -> getCode ( ) , ] ; } if ( ! in_array ( Options :: SERIALIZE_MINIMAL , $ options ) ) { $ serializedNode = array_merge ( $ serializedNode , [ 'display' => $ this -> serializeDisplay ( $ resourceNode ) , 'restrictions' => $ this -> serializeRestrictions ( $ resourceNode ) , ] ) ; } //maybe don't remove me, it's used by the export system $ parent = $ resourceNode -> getParent ( ) ; if ( ! empty ( $ parent ) ) { $ serializedNode [ 'parent' ] = [ 'id' => $ parent -> getUuid ( ) , 'autoId' => $ parent -> getId ( ) , // TODO : remove me 'name' => $ parent -> getName ( ) , ] ; } if ( ! in_array ( Options :: SERIALIZE_MINIMAL , $ options ) ) { $ serializedNode [ 'comments' ] = array_map ( function ( ResourceComment $ comment ) { return $ this -> serializer -> serialize ( $ comment ) ; } , $ resourceNode -> getComments ( ) -> toArray ( ) ) ; } $ serializedNode = $ this -> decorate ( $ resourceNode , $ serializedNode , $ options ) ; return $ serializedNode ; }
Serializes a ResourceNode entity for the JSON api.

@param ResourceNode $resourceNode - the node to serialize
@param array        $options

@return array - the serialized representation of the node
Serializes a ResourceNode entity for the JSON api .