public function onSerialize(DecorateResourceNodeEvent $event)
    {
        $options = $event->getOptions();

        if (!in_array(Options::SKIP_RESOURCE_NOTIFICATION, $options)) {
            $node = $event->getResourceNode();
            $user = $this->tokenStorage->getToken()->getUser();
            $followResource = $user !== 'anon.' ?
                $this->notificationManager->getFollowerResource(
                    $user->getId(),
                    $node->getId(),
                    $node->getClass()
                ) :
                false;

            $event->add('notifications', ['enabled' => !empty($followResource)]);
        }
    }
public function onSerialize(DecorateResourceNodeEvent $event)
    {
        $options = $event->getOptions();

        if (!in_array(Options::SKIP_RESOURCE_NOTIFICATION, $options)) {
            $node = $event->getResourceNode();
            $user = $this->tokenStorage->getToken()->getUser();
            $followResource = $user !== 'anon.' ?
                $this->notificationManager->getFollowerResource(
                    $user->getId(),
                    $node->getId(),
                    $node->getClass()
                ) :
                false;

            $event->add('notifications', ['enabled' => !empty($followResource)]);
        }
    }
public function onSerialize ( DecorateResourceNodeEvent $ event ) { $ options = $ event -> getOptions ( ) ; if ( ! in_array ( Options :: SKIP_RESOURCE_NOTIFICATION , $ options ) ) { $ node = $ event -> getResourceNode ( ) ; $ user = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; $ followResource = $ user !== 'anon.' ? $ this -> notificationManager -> getFollowerResource ( $ user -> getId ( ) , $ node -> getId ( ) , $ node -> getClass ( ) ) : false ; $ event -> add ( 'notifications' , [ 'enabled' => ! empty ( $ followResource ) ] ) ; } }
Add notifications option to serialized resource node when requested through API.

@DI\Observe("serialize_resource_node")
Add notifications option to serialized resource node when requested through API .