src/Sulu/Bundle/PageBundle/Serializer/Subscriber/RedirectTypeSubscriber.php
public function onPostSerialize(ObjectEvent $event)
    {
        /** @var RedirectTypeBehavior $document */
        $document = $event->getObject();

        if (!$document instanceof RedirectTypeBehavior) {
            return;
        }

        $visitor = $event->getVisitor();

        $redirectType = $document->getRedirectType();

        if (RedirectType::INTERNAL == $redirectType && null !== $document->getRedirectTarget()) {
            $visitor->addData('linked', 'internal');
            $visitor->addData('internal_link', $document->getRedirectTarget()->getUuid());
        } elseif (RedirectType::EXTERNAL == $redirectType) {
            $visitor->addData('linked', 'external');
            $visitor->addData('external', $document->getRedirectExternal());
        } else {
            $visitor->addData('linked', null);
        }
    }
public function onPostSerialize(ObjectEvent $event)
    {
        /** @var RedirectTypeBehavior $document */
        $document = $event->getObject();

        if (!$document instanceof RedirectTypeBehavior) {
            return;
        }

        $visitor = $event->getVisitor();

        $redirectType = $document->getRedirectType();

        if (RedirectType::INTERNAL == $redirectType && null !== $document->getRedirectTarget()) {
            $visitor->addData('linked', 'internal');
            $visitor->addData('internal_link', $document->getRedirectTarget()->getUuid());
        } elseif (RedirectType::EXTERNAL == $redirectType) {
            $visitor->addData('linked', 'external');
            $visitor->addData('external', $document->getRedirectExternal());
        } else {
            $visitor->addData('linked', null);
        }
    }
public function onPostSerialize ( ObjectEvent $ event ) { /** @var RedirectTypeBehavior $document */ $ document = $ event -> getObject ( ) ; if ( ! $ document instanceof RedirectTypeBehavior ) { return ; } $ visitor = $ event -> getVisitor ( ) ; $ redirectType = $ document -> getRedirectType ( ) ; if ( RedirectType :: INTERNAL == $ redirectType && null !== $ document -> getRedirectTarget ( ) ) { $ visitor -> addData ( 'linked' , 'internal' ) ; $ visitor -> addData ( 'internal_link' , $ document -> getRedirectTarget ( ) -> getUuid ( ) ) ; } elseif ( RedirectType :: EXTERNAL == $ redirectType ) { $ visitor -> addData ( 'linked' , 'external' ) ; $ visitor -> addData ( 'external' , $ document -> getRedirectExternal ( ) ) ; } else { $ visitor -> addData ( 'linked' , null ) ; } }
Adds the type of redirect and the redirect location to the serialization.

@param ObjectEvent $event
Adds the type of redirect and the redirect location to the serialization .