main/core/API/Serializer/Resource/ResourceNodeSerializer.php
private function decorate(ResourceNode $resourceNode, array $serializedNode, array $options = [])
    {
        // avoid plugins override the standard node properties
        $unauthorizedKeys = array_keys($serializedNode);

        // 'thumbnail' is a key that can be overridden by another plugin. For example: UrlBundle
        // TODO : find a cleaner way to do it
        if (false !== ($key = array_search('thumbnail', $unauthorizedKeys))) {
            unset($unauthorizedKeys[$key]);
        }

        /** @var DecorateResourceNodeEvent $event */
        $event = $this->eventDispatcher->dispatch(
            'serialize_resource_node',
            'Resource\DecorateResourceNode',
            [
                $resourceNode,
                $unauthorizedKeys,
                $options,
            ]
        );

        return array_merge($serializedNode, $event->getInjectedData());
    }
private function decorate(ResourceNode $resourceNode, array $serializedNode, array $options = [])
    {
        // avoid plugins override the standard node properties
        $unauthorizedKeys = array_keys($serializedNode);

        // 'thumbnail' is a key that can be overridden by another plugin. For example: UrlBundle
        // TODO : find a cleaner way to do it
        if (false !== ($key = array_search('thumbnail', $unauthorizedKeys))) {
            unset($unauthorizedKeys[$key]);
        }

        /** @var DecorateResourceNodeEvent $event */
        $event = $this->eventDispatcher->dispatch(
            'serialize_resource_node',
            'Resource\DecorateResourceNode',
            [
                $resourceNode,
                $unauthorizedKeys,
                $options,
            ]
        );

        return array_merge($serializedNode, $event->getInjectedData());
    }
private function decorate ( ResourceNode $ resourceNode , array $ serializedNode , array $ options = [ ] ) { // avoid plugins override the standard node properties $ unauthorizedKeys = array_keys ( $ serializedNode ) ; // 'thumbnail' is a key that can be overridden by another plugin. For example: UrlBundle // TODO : find a cleaner way to do it if ( false !== ( $ key = array_search ( 'thumbnail' , $ unauthorizedKeys ) ) ) { unset ( $ unauthorizedKeys [ $ key ] ) ; } /** @var DecorateResourceNodeEvent $event */ $ event = $ this -> eventDispatcher -> dispatch ( 'serialize_resource_node' , 'Resource\DecorateResourceNode' , [ $ resourceNode , $ unauthorizedKeys , $ options , ] ) ; return array_merge ( $ serializedNode , $ event -> getInjectedData ( ) ) ; }
Dispatches an event to let plugins add some custom data to the serialized node.
For example, SocialMedia adds the number of likes.

@param ResourceNode $resourceNode   - the original node entity
@param array        $serializedNode - the serialized version of the node
@param array        $options

@return array - the decorated node
Dispatches an event to let plugins add some custom data to the serialized node . For example SocialMedia adds the number of likes .