function BigPipeTestSubscriber::onRespondTriggerException

Same name and namespace in other branches
  1. 9 core/modules/big_pipe/tests/modules/big_pipe_test/src/EventSubscriber/BigPipeTestSubscriber.php \Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber::onRespondTriggerException()
  2. 8.9.x core/modules/big_pipe/tests/modules/big_pipe_test/src/EventSubscriber/BigPipeTestSubscriber.php \Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber::onRespondTriggerException()
  3. 10 core/modules/big_pipe/tests/modules/big_pipe_test/src/EventSubscriber/BigPipeTestSubscriber.php \Drupal\big_pipe_test\EventSubscriber\BigPipeTestSubscriber::onRespondTriggerException()

Triggers exception for embedded HTML/AJAX responses with certain content.

Parameters

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

Throws

\Exception

See also

\Drupal\big_pipe_test\BigPipeTestController::responseException()

File

core/modules/big_pipe/tests/modules/big_pipe_test/src/EventSubscriber/BigPipeTestSubscriber.php, line 30

Class

BigPipeTestSubscriber

Namespace

Drupal\big_pipe_test\EventSubscriber

Code

public function onRespondTriggerException(ResponseEvent $event) {
    $response = $event->getResponse();
    if (!$response instanceof AttachmentsInterface) {
        return;
    }
    $attachments = $response->getAttachments();
    if (!isset($attachments['big_pipe_placeholders']) && !isset($attachments['big_pipe_nojs_placeholders'])) {
        if (str_contains($response->getContent(), static::CONTENT_TRIGGER_EXCEPTION)) {
            throw new \Exception('Oh noes!');
        }
    }
}

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