<?php
namespace Boab\CmsBundle\EventListener;
use Boab\CmsBundle\Events;
use Boab\CmsBundle\Event\PageShowEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Tchoulom\ViewCounterBundle\Counter\ViewCounter as Counter;
class ViewCounterSubscriber implements EventSubscriberInterface
{
/**
* @var Counter
*/
protected $viewcounter;
/**
* @param Counter $viewCounter
*/
public function __construct(Counter $viewCounter)
{
$this->viewcounter = $viewCounter;
}
public function onPageShow(PageShowEvent $event)
{
$content = $event->getNode();
$this->viewcounter->saveView($content);
}
public static function getSubscribedEvents():array
{
return [
Events::PAGE_SHOW => ['onPageShow']
];
}
}