class TestClass

Hierarchy

Expanded class hierarchy of TestClass

1 string reference to 'TestClass'
bundle_test.services.yml in drupal/core/modules/system/tests/modules/bundle_test/bundle_test.services.yml
drupal/core/modules/system/tests/modules/bundle_test/bundle_test.services.yml
1 service uses TestClass
bundle_test_class in drupal/core/modules/system/tests/modules/bundle_test/bundle_test.services.yml
Drupal\bundle_test\TestClass

File

drupal/core/modules/system/tests/modules/bundle_test/lib/Drupal/bundle_test/TestClass.php, line 16
Definition of Drupal\bundle_test\TestClass.

Namespace

Drupal\bundle_test
View source
class TestClass implements EventSubscriberInterface, DestructableInterface {

  /**
   * The state keyvalue collection.
   *
   * @var \Drupal\Core\KeyValueStore\KeyValueStoreInterface
   */
  protected $state;

  /**
   * Constructor.
   *
   * @param \Drupal\Core\KeyValueStore\KeyValueStoreInterface $state
   *   The state key value store.
   */
  public function __construct(KeyValueStoreInterface $state) {
    $this->state = $state;
  }

  /**
   * A simple kernel listener method.
   */
  public function onKernelRequestTest(GetResponseEvent $event) {
    drupal_set_message(t('The bundle_test event subscriber fired!'));
  }

  /**
   * Registers methods as kernel listeners.
   *
   * @return array
   *   An array of event listener definitions.
   */
  static function getSubscribedEvents() {
    $events[KernelEvents::REQUEST][] = array(
      'onKernelRequestTest',
      100,
    );
    return $events;
  }

  /**
   * Implements \Drupal\Core\DestructableInterface::destruct().
   */
  public function destruct() {
    $this->state
      ->set('bundle_test.destructed', TRUE);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
TestClass::$state protected property The state keyvalue collection.
TestClass::destruct public function Implements \Drupal\Core\DestructableInterface::destruct(). Overrides DestructableInterface::destruct
TestClass::getSubscribedEvents static function Registers methods as kernel listeners. Overrides EventSubscriberInterface::getSubscribedEvents
TestClass::onKernelRequestTest public function A simple kernel listener method.
TestClass::__construct public function Constructor.