You are here

class MockSubscriber in Akamai 8.3

Mock Event Subscriber for testing.

Hierarchy

  • class \Drupal\Tests\akamai\Kernel\EventSubscriber\MockSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface

Expanded class hierarchy of MockSubscriber

1 file declares its use of MockSubscriber
AkamaiTagPurgerTest.php in tests/src/Unit/Plugin/Purge/Purger/AkamaiTagPurgerTest.php

File

tests/src/Kernel/EventSubscriber/MockSubscriber.php, line 12

Namespace

Drupal\Tests\akamai\Kernel\EventSubscriber
View source
class MockSubscriber implements EventSubscriberInterface {

  /**
   * Storage of the last event.
   *
   * @var Symfony\Component\EventDispatcher\Event
   */
  public $event;

  /**
   * {@inheritdoc}
   */
  public static function getSubscribedEvents() {
    $events[AkamaiHeaderEvents::HEADER_CREATION][] = [
      'onHeaderCreation',
    ];
    $events[AkamaiPurgeEvents::PURGE_CREATION][] = [
      'onPurgeCreation',
    ];
    return $events;
  }

  /**
   * Add cache tags header on cacheable responses.
   *
   * @param \Drupal\akamai\Event\AkamaiHeaderEvents $event
   *   The event to process.
   */
  public function onHeaderCreation(AkamaiHeaderEvents $event) {
    $this->event = $event;
    $event->data[] = 'on_header_creation';
  }

  /**
   * Process purge creation event.
   *
   * @param \Drupal\akamai\Event\AkamaiPurgeEvents $event
   *   The event to process.
   */
  public function onPurgeCreation(AkamaiPurgeEvents $event) {
    $this->event = $event;
    $event->data[] = 'on_purge_creation';
  }

}

Members

Namesort descending Modifiers Type Description Overrides
MockSubscriber::$event public property Storage of the last event.
MockSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
MockSubscriber::onHeaderCreation public function Add cache tags header on cacheable responses.
MockSubscriber::onPurgeCreation public function Process purge creation event.