src/Sulu/Bundle/SecurityBundle/Serializer/Subscriber/SecuritySubscriber.php
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();

        if (!($document instanceof SecurityBehavior
            && $document instanceof LocaleBehavior
            && $document instanceof WebspaceBehavior
            && null !== $this->tokenStorage
            && null !== $this->tokenStorage->getToken()
            && $this->tokenStorage->getToken()->getUser() instanceof UserInterface)
        ) {
            return;
        }

        /** @var JsonSerializationVisitor $visitor */
        $visitor = $event->getVisitor();

        $visitor->addData(
            '_permissions',
            $this->accessControlManager->getUserPermissionByArray(
                $document->getLocale(),
                PageAdmin::SECURITY_CONTEXT_PREFIX . $document->getWebspaceName(),
                $document->getPermissions(),
                $this->tokenStorage->getToken()->getUser()
            )
        );
    }
public function onPostSerialize(ObjectEvent $event)
    {
        $document = $event->getObject();

        if (!($document instanceof SecurityBehavior
            && $document instanceof LocaleBehavior
            && $document instanceof WebspaceBehavior
            && null !== $this->tokenStorage
            && null !== $this->tokenStorage->getToken()
            && $this->tokenStorage->getToken()->getUser() instanceof UserInterface)
        ) {
            return;
        }

        /** @var JsonSerializationVisitor $visitor */
        $visitor = $event->getVisitor();

        $visitor->addData(
            '_permissions',
            $this->accessControlManager->getUserPermissionByArray(
                $document->getLocale(),
                PageAdmin::SECURITY_CONTEXT_PREFIX . $document->getWebspaceName(),
                $document->getPermissions(),
                $this->tokenStorage->getToken()->getUser()
            )
        );
    }
public function onPostSerialize ( ObjectEvent $ event ) { $ document = $ event -> getObject ( ) ; if ( ! ( $ document instanceof SecurityBehavior && $ document instanceof LocaleBehavior && $ document instanceof WebspaceBehavior && null !== $ this -> tokenStorage && null !== $ this -> tokenStorage -> getToken ( ) && $ this -> tokenStorage -> getToken ( ) -> getUser ( ) instanceof UserInterface ) ) { return ; } /** @var JsonSerializationVisitor $visitor */ $ visitor = $ event -> getVisitor ( ) ; $ visitor -> addData ( '_permissions' , $ this -> accessControlManager -> getUserPermissionByArray ( $ document -> getLocale ( ) , PageAdmin :: SECURITY_CONTEXT_PREFIX . $ document -> getWebspaceName ( ) , $ document -> getPermissions ( ) , $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ) ) ; }
Adds the permissions for the current user to the serialization.

@param ObjectEvent $event
Adds the permissions for the current user to the serialization .