You are here

class TestClass in Zircon Profile 8

Same name in this branch
  1. 8 vendor/sebastian/comparator/tests/_files/TestClass.php \SebastianBergmann\Comparator\TestClass
  2. 8 vendor/phpunit/php-token-stream/tests/_fixture/classInNamespace.php \Foo\Bar\TestClass
  3. 8 vendor/phpunit/php-token-stream/tests/_fixture/classInScopedNamespace.php \Foo\BarScoped\TestClass
  4. 8 vendor/phpunit/php-token-stream/tests/_fixture/issue19.php \TestClass
  5. 8 core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\Tests\Core\TypedData\TestClass
  6. 8 core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass
  7. 8 core/modules/simpletest/tests/src/Unit/AssertContentTraitTest.php \Drupal\Tests\simpletest\Unit\TestClass
  8. 8 core/modules/system/tests/modules/service_provider_test/src/TestClass.php \Drupal\service_provider_test\TestClass
  9. 8 vendor/doctrine/common/tests/Doctrine/Tests/Common/Persistence/Mapping/_files/annotation/TestClass.php \Doctrine\TestClass
Same name and namespace in other branches
  1. 8.0 core/modules/system/tests/modules/service_provider_test/src/TestClass.php \Drupal\service_provider_test\TestClass

Hierarchy

Expanded class hierarchy of TestClass

3 string references to 'TestClass'
ErrorTest::providerTestFormatBacktrace in core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
Data provider for testFormatBacktrace.
ErrorTest::providerTestGetLastCaller in core/tests/Drupal/Tests/Core/Utility/ErrorTest.php
Data provider for testGetLastCaller.
service_provider_test.services.yml in core/modules/system/tests/modules/service_provider_test/service_provider_test.services.yml
core/modules/system/tests/modules/service_provider_test/service_provider_test.services.yml
1 service uses TestClass
service_provider_test_class in core/modules/system/tests/modules/service_provider_test/service_provider_test.services.yml
Drupal\service_provider_test\TestClass

File

core/modules/system/tests/modules/service_provider_test/src/TestClass.php, line 19
Contains \Drupal\service_provider_test\TestClass.

Namespace

Drupal\service_provider_test
View source
class TestClass implements EventSubscriberInterface, DestructableInterface, ContainerAwareInterface {
  use ContainerAwareTrait;

  /**
   * The state keyvalue collection.
   *
   * @var \Drupal\Core\State\StateInterface
   */
  protected $state;

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

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

  /**
   * Flags the response in case a rebuild indicator is used.
   */
  public function onKernelResponseTest(FilterResponseEvent $event) {
    if ($this->container
      ->hasParameter('container_rebuild_indicator')) {
      $event
        ->getResponse()->headers
        ->set('container_rebuild_indicator', $this->container
        ->getParameter('container_rebuild_indicator'));
    }
    if ($this->container
      ->hasParameter('container_rebuild_test_parameter')) {
      $event
        ->getResponse()->headers
        ->set('container_rebuild_test_parameter', $this->container
        ->getParameter('container_rebuild_test_parameter'));
    }
  }

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

  /**
   * {@inheritdoc}
   */
  public function destruct() {
    $this->state
      ->set('service_provider_test.destructed', TRUE);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ContainerAwareTrait::$container protected property
ContainerAwareTrait::setContainer public function Sets the Container associated with this Controller.
TestClass::$state protected property The state keyvalue collection.
TestClass::destruct public function Performs destruct operations. 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::onKernelResponseTest public function Flags the response in case a rebuild indicator is used.
TestClass::__construct public function Constructor.