src/Sulu/Bundle/CustomUrlBundle/EventListener/CustomUrlSerializeEventSubscriber.php
public function onPostSerialize(ObjectEvent $event)
    {
        $customUrl = $event->getObject();
        $visitor = $event->getVisitor();

        if (!$customUrl instanceof CustomUrlDocument) {
            return;
        }

        if (null !== $customUrl->getTargetDocument()) {
            $visitor->addData('targetTitle', $customUrl->getTargetDocument()->getTitle());
            $visitor->addData('targetDocument', $customUrl->getTargetDocument()->getUuid());
        }

        $visitor->addData(
            'customUrl',
            $this->generator->generate($customUrl->getBaseDomain(), $customUrl->getDomainParts())
        );

        $visitor->addData('creatorFullName', $this->userManager->getFullNameByUserId($customUrl->getCreator()));
        $visitor->addData('changerFullName', $this->userManager->getFullNameByUserId($customUrl->getChanger()));
    }
public function onPostSerialize(ObjectEvent $event)
    {
        $customUrl = $event->getObject();
        $visitor = $event->getVisitor();

        if (!$customUrl instanceof CustomUrlDocument) {
            return;
        }

        if (null !== $customUrl->getTargetDocument()) {
            $visitor->addData('targetTitle', $customUrl->getTargetDocument()->getTitle());
            $visitor->addData('targetDocument', $customUrl->getTargetDocument()->getUuid());
        }

        $visitor->addData(
            'customUrl',
            $this->generator->generate($customUrl->getBaseDomain(), $customUrl->getDomainParts())
        );

        $visitor->addData('creatorFullName', $this->userManager->getFullNameByUserId($customUrl->getCreator()));
        $visitor->addData('changerFullName', $this->userManager->getFullNameByUserId($customUrl->getChanger()));
    }
public function onPostSerialize ( ObjectEvent $ event ) { $ customUrl = $ event -> getObject ( ) ; $ visitor = $ event -> getVisitor ( ) ; if ( ! $ customUrl instanceof CustomUrlDocument ) { return ; } if ( null !== $ customUrl -> getTargetDocument ( ) ) { $ visitor -> addData ( 'targetTitle' , $ customUrl -> getTargetDocument ( ) -> getTitle ( ) ) ; $ visitor -> addData ( 'targetDocument' , $ customUrl -> getTargetDocument ( ) -> getUuid ( ) ) ; } $ visitor -> addData ( 'customUrl' , $ this -> generator -> generate ( $ customUrl -> getBaseDomain ( ) , $ customUrl -> getDomainParts ( ) ) ) ; $ visitor -> addData ( 'creatorFullName' , $ this -> userManager -> getFullNameByUserId ( $ customUrl -> getCreator ( ) ) ) ; $ visitor -> addData ( 'changerFullName' , $ this -> userManager -> getFullNameByUserId ( $ customUrl -> getChanger ( ) ) ) ; }
Add information to serialized custom-url document.

@param ObjectEvent $event
Add information to serialized custom - url document .