You are here

public function TestDomainObjectViewSubscriber::onViewTestDomainObject in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/system/tests/modules/early_rendering_controller_test/src/TestDomainObjectViewSubscriber.php \Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber::onViewTestDomainObject()

Sets a response given a TestDomainObject instance.

Parameters

\Symfony\Component\HttpKernel\Event\GetResponseForControllerResultEvent $event: The event to process.

File

core/modules/system/tests/modules/early_rendering_controller_test/src/TestDomainObjectViewSubscriber.php, line 26
Contains \Drupal\early_rendering_controller_test\TestDomainObjectViewSubscriber.

Class

TestDomainObjectViewSubscriber
View subscriber for turning TestDomainObject objects into Response objects.

Namespace

Drupal\early_rendering_controller_test

Code

public function onViewTestDomainObject(GetResponseForControllerResultEvent $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'));
    }
  }
}