class TestClass

Same name in this branch
  1. 8.9.x core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Unit\TestClass
  2. 8.9.x core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\Tests\Core\TypedData\TestClass
  3. 8.9.x core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php \Drupal\Tests\Core\Test\TestClass
  4. 8.9.x core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php \Drupal\Tests\Core\Plugin\TestClass
  5. 8.9.x core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass
Same name and namespace in other branches
  1. 9 core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Unit\TestClass
  2. 9 core/modules/system/tests/modules/service_provider_test/src/TestClass.php \Drupal\service_provider_test\TestClass
  3. 9 core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php \Drupal\Tests\Core\Test\TestClass
  4. 9 core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php \Drupal\Tests\Core\Plugin\TestClass
  5. 9 core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass
  6. 10 core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Unit\TestClass
  7. 10 core/modules/system/tests/modules/service_provider_test/src/TestClass.php \Drupal\service_provider_test\TestClass
  8. 10 core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php \Drupal\Tests\Core\Plugin\TestClass
  9. 10 core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass
  10. 11.x core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Unit\TestClass
  11. 11.x core/modules/system/tests/modules/service_provider_test/src/TestClass.php \Drupal\service_provider_test\TestClass
  12. 11.x core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php \Drupal\Tests\Core\Plugin\TestClass
  13. 11.x core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass

Hierarchy

  • class \Drupal\service_provider_test\TestClass implements \Symfony\Component\EventDispatcher\EventSubscriberInterface, \Drupal\Core\DestructableInterface, \Symfony\Component\DependencyInjection\ContainerAwareInterface uses \Symfony\Component\DependencyInjection\ContainerAwareTrait

Expanded class hierarchy of TestClass

5 string references to 'TestClass'
AuthenticationProviderPassTest::testEncoders in core/tests/Drupal/Tests/Core/DependencyInjection/Compiler/AuthenticationProviderPassTest.php
@covers ::process
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.
RegisterSerializationClassesCompilerPassTest::testEncoders in core/modules/serialization/tests/src/Unit/CompilerPass/RegisterSerializationClassesCompilerPassTest.php
@covers ::process
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 14

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::messenger()->addStatus(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.
     */
    public static function getSubscribedEvents() {
        $events[KernelEvents::REQUEST][] = [
            'onKernelRequestTest',
        ];
        $events[KernelEvents::RESPONSE][] = [
            'onKernelResponseTest',
        ];
        return $events;
    }
    
    /**
     * {@inheritdoc}
     */
    public function destruct() {
        $this->state
            ->set('service_provider_test.destructed', TRUE);
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title
TestClass::$state protected property The state keyvalue collection.
TestClass::destruct public function Performs destruct operations. Overrides DestructableInterface::destruct
TestClass::getSubscribedEvents public static function Registers methods as kernel listeners.
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.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.