lib/boab/cms-bundle/src/EventListener/ViewCounterSubscriber.php line 25

Open in your IDE?
  1. <?php
  2. namespace Boab\CmsBundle\EventListener;
  3. use Boab\CmsBundle\Events;
  4. use Boab\CmsBundle\Event\PageShowEvent;
  5. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  6. use Tchoulom\ViewCounterBundle\Counter\ViewCounter as Counter;
  7. class ViewCounterSubscriber implements EventSubscriberInterface
  8. {
  9.     /**
  10.      * @var Counter
  11.      */
  12.     protected $viewcounter;
  13.     /**
  14.      * @param Counter $viewCounter
  15.      */
  16.     public function __construct(Counter $viewCounter)
  17.     {
  18.         $this->viewcounter $viewCounter;
  19.     }
  20.     public function onPageShow(PageShowEvent $event)
  21.     {
  22.         $content $event->getNode();
  23.         
  24.         $this->viewcounter->saveView($content);
  25.     }
  26.     public static function getSubscribedEvents():array
  27.     {
  28.         return [
  29.            Events::PAGE_SHOW => ['onPageShow']
  30.         ];
  31.     }    
  32. }