class TestClass

Same name in this branch
  1. 10 core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Unit\TestClass
  2. 10 core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php \Drupal\Tests\Core\Plugin\TestClass
  3. 10 core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass
Same name 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. 8.9.x core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Unit\TestClass
  7. 8.9.x core/modules/system/tests/modules/service_provider_test/src/TestClass.php \Drupal\service_provider_test\TestClass
  8. 8.9.x core/tests/Drupal/Tests/Core/TypedData/RecursiveContextualValidatorTest.php \Drupal\Tests\Core\TypedData\TestClass
  9. 8.9.x core/tests/Drupal/Tests/Core/Test/AssertContentTraitTest.php \Drupal\Tests\Core\Test\TestClass
  10. 8.9.x core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php \Drupal\Tests\Core\Plugin\TestClass
  11. 8.9.x core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass
  12. 11.x core/modules/layout_builder/tests/src/Unit/LayoutEntityHelperTraitTest.php \Drupal\Tests\layout_builder\Unit\TestClass
  13. 11.x core/modules/system/tests/modules/service_provider_test/src/TestClass.php \Drupal\service_provider_test\TestClass
  14. 11.x core/tests/Drupal/Tests/Core/Plugin/PluginWithFormsTraitTest.php \Drupal\Tests\Core\Plugin\TestClass
  15. 11.x core/tests/Drupal/Tests/Component/Utility/ArgumentsResolverTest.php \Drupal\Tests\Component\Utility\TestClass

Hierarchy

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 12

Namespace

Drupal\service_provider_test
View source
class TestClass implements EventSubscriberInterface, DestructableInterface {
    
    /**
     * 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(RequestEvent $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(ResponseEvent $event) {
        $container = \Drupal::getContainer();
        if ($container->hasParameter('container_rebuild_indicator')) {
            $event->getResponse()->headers
                ->set('container_rebuild_indicator', $container->getParameter('container_rebuild_indicator'));
        }
        if ($container->hasParameter('container_rebuild_test_parameter')) {
            $event->getResponse()->headers
                ->set('container_rebuild_test_parameter', $container->getParameter('container_rebuild_test_parameter'));
        }
    }
    
    /**
     * Registers methods as kernel listeners.
     *
     * @return array
     *   An array of event listener definitions.
     */
    public static function getSubscribedEvents() : array {
        $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.