Caching Event Subcriber

by monkeyUser   Last Updated March 13, 2016 08:03 AM

I create an event and a subscriber like this

service

services:
  courtesypage.not_found:
    class: Drupal\courtesypage\DefaultService
    arguments: []
    tags:
      - { name: event_subscriber }


namespace Drupal\courtesypage;

use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;

class DefaultService implements EventSubscriberInterface {

  public static function getSubscribedEvents() {
    $a = 0;
    // return the subscribed events, their methods and priorities
    return array(
      'kernel.request' => array(
        array('checkForRedirection')
      )
    );
  }

  public function checkForRedirection(GetResponseEvent $event) {
    // ...
     $i=0;
    }
  }
  }

When I clear the cache the first time enter in checkForRedirection, but after it seems cached.



Related Questions


Hook or event before a page gets cached

Updated July 11, 2018 20:07 PM

Event does not trigger each time I load a page

Updated July 29, 2016 08:03 AM



How can an event subscriber have access to entity type?

Updated November 17, 2017 23:07 PM