plugin/social-media/Listener/ApiListener.php
public function onSerialize(DecorateResourceNodeEvent $event)
    {
        $count = $this->om->getRepository('IcapSocialmediaBundle:LikeAction')->countLikes([
            'resource' => $event->getResourceNode()->getId(),
        ]);

        $event->add('social', [
            'likes' => $count,
        ]);
    }
public function onSerialize(DecorateResourceNodeEvent $event)
    {
        $count = $this->om->getRepository('IcapSocialmediaBundle:LikeAction')->countLikes([
            'resource' => $event->getResourceNode()->getId(),
        ]);

        $event->add('social', [
            'likes' => $count,
        ]);
    }
public function onSerialize ( DecorateResourceNodeEvent $ event ) { $ count = $ this -> om -> getRepository ( 'IcapSocialmediaBundle:LikeAction' ) -> countLikes ( [ 'resource' => $ event -> getResourceNode ( ) -> getId ( ) , ] ) ; $ event -> add ( 'social' , [ 'likes' => $ count , ] ) ; }
Add like count to serialized resource node when requested through API.

@DI\Observe("serialize_resource_node")

@param DecorateResourceNodeEvent $event
Add like count to serialized resource node when requested through API .