src/Sulu/Component/Content/Repository/Serializer/SerializerEventListener.php
public function onPostSerialize(ObjectEvent $event)
    {
        /** @var Content $content */
        $content = $event->getObject();
        /** @var JsonSerializationVisitor $visitor */
        $visitor = $event->getVisitor();

        if (!($content instanceof Content)) {
            return;
        }

        foreach ($content->getData() as $key => $value) {
            $visitor->setData($key, $value);
        }

        $visitor->setData('publishedState', (WorkflowStage::PUBLISHED === $content->getWorkflowStage()));

        if (RedirectType::EXTERNAL === $content->getNodeType()) {
            $visitor->setData('linked', 'external');
        } elseif (RedirectType::INTERNAL === $content->getNodeType()) {
            $visitor->setData('linked', 'internal');
        }

        if (null !== $content->getLocalizationType()) {
            $visitor->setData('type', $content->getLocalizationType()->toArray());
        }

        $visitor->setData(
            '_permissions',
            $this->accessControlManager->getUserPermissionByArray(
                $content->getLocale(),
                PageAdmin::SECURITY_CONTEXT_PREFIX . $content->getWebspaceKey(),
                $content->getPermissions(),
                $this->tokenStorage->getToken()->getUser()
            )
        );
    }
public function onPostSerialize(ObjectEvent $event)
    {
        /** @var Content $content */
        $content = $event->getObject();
        /** @var JsonSerializationVisitor $visitor */
        $visitor = $event->getVisitor();

        if (!($content instanceof Content)) {
            return;
        }

        foreach ($content->getData() as $key => $value) {
            $visitor->setData($key, $value);
        }

        $visitor->setData('publishedState', (WorkflowStage::PUBLISHED === $content->getWorkflowStage()));

        if (RedirectType::EXTERNAL === $content->getNodeType()) {
            $visitor->setData('linked', 'external');
        } elseif (RedirectType::INTERNAL === $content->getNodeType()) {
            $visitor->setData('linked', 'internal');
        }

        if (null !== $content->getLocalizationType()) {
            $visitor->setData('type', $content->getLocalizationType()->toArray());
        }

        $visitor->setData(
            '_permissions',
            $this->accessControlManager->getUserPermissionByArray(
                $content->getLocale(),
                PageAdmin::SECURITY_CONTEXT_PREFIX . $content->getWebspaceKey(),
                $content->getPermissions(),
                $this->tokenStorage->getToken()->getUser()
            )
        );
    }
public function onPostSerialize ( ObjectEvent $ event ) { /** @var Content $content */ $ content = $ event -> getObject ( ) ; /** @var JsonSerializationVisitor $visitor */ $ visitor = $ event -> getVisitor ( ) ; if ( ! ( $ content instanceof Content ) ) { return ; } foreach ( $ content -> getData ( ) as $ key => $ value ) { $ visitor -> setData ( $ key , $ value ) ; } $ visitor -> setData ( 'publishedState' , ( WorkflowStage :: PUBLISHED === $ content -> getWorkflowStage ( ) ) ) ; if ( RedirectType :: EXTERNAL === $ content -> getNodeType ( ) ) { $ visitor -> setData ( 'linked' , 'external' ) ; } elseif ( RedirectType :: INTERNAL === $ content -> getNodeType ( ) ) { $ visitor -> setData ( 'linked' , 'internal' ) ; } if ( null !== $ content -> getLocalizationType ( ) ) { $ visitor -> setData ( 'type' , $ content -> getLocalizationType ( ) -> toArray ( ) ) ; } $ visitor -> setData ( '_permissions' , $ this -> accessControlManager -> getUserPermissionByArray ( $ content -> getLocale ( ) , PageAdmin :: SECURITY_CONTEXT_PREFIX . $ content -> getWebspaceKey ( ) , $ content -> getPermissions ( ) , $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ) ) ; }
Add data for serialization of content objects.

@param ObjectEvent $event
Add data for serialization of content objects .