class TestDomainObjectViewSubscriber
Same name in other branches
- 8.9.x core/modules/system/tests/modules/early_rendering_controller_test/src/TestDomainObjectViewSubscriber.php \Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber
- 10 core/modules/system/tests/modules/early_rendering_controller_test/src/TestDomainObjectViewSubscriber.php \Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber
- 11.x core/modules/system/tests/modules/early_rendering_controller_test/src/TestDomainObjectViewSubscriber.php \Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber
View subscriber for turning TestDomainObject objects into Response objects.
Hierarchy
- class \Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber implements \Symfony\Component\EventDispatcher\EventSubscriberInterface
Expanded class hierarchy of TestDomainObjectViewSubscriber
1 string reference to 'TestDomainObjectViewSubscriber'
- early_rendering_controller_test.services.yml in core/
modules/ system/ tests/ modules/ early_rendering_controller_test/ early_rendering_controller_test.services.yml - core/modules/system/tests/modules/early_rendering_controller_test/early_rendering_controller_test.services.yml
1 service uses TestDomainObjectViewSubscriber
- test_domain_object.view_subscriber in core/
modules/ system/ tests/ modules/ early_rendering_controller_test/ early_rendering_controller_test.services.yml - Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber
File
-
core/
modules/ system/ tests/ modules/ early_rendering_controller_test/ src/ TestDomainObjectViewSubscriber.php, line 13
Namespace
Drupal\early_rendering_controller_testView source
class TestDomainObjectViewSubscriber implements EventSubscriberInterface {
/**
* Sets a response given a TestDomainObject instance.
*
* @param \Symfony\Component\HttpKernel\Event\ViewEvent $event
* The event to process.
*/
public function onViewTestDomainObject(ViewEvent $event) {
$result = $event->getControllerResult();
if ($result instanceof TestDomainObject) {
if ($result instanceof AttachmentsTestDomainObject) {
$event->setResponse(new AttachmentsTestResponse('AttachmentsTestDomainObject'));
}
elseif ($result instanceof CacheableTestDomainObject) {
$event->setResponse(new CacheableTestResponse('CacheableTestDomainObject'));
}
else {
$event->setResponse(new Response('TestDomainObject'));
}
}
}
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents() {
$events[KernelEvents::VIEW][] = [
'onViewTestDomainObject',
];
return $events;
}
}
Members
Title Sort descending | Modifiers | Object type | Summary |
---|---|---|---|
TestDomainObjectViewSubscriber::getSubscribedEvents | public static | function | |
TestDomainObjectViewSubscriber::onViewTestDomainObject | public | function | Sets a response given a TestDomainObject instance. |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.