You are here

class HtmlResponseBigPipeSessionlessSubscriber in Sessionless BigPipe 8

Same name and namespace in other branches
  1. 2.x src/EventSubscriber/HtmlResponseBigPipeSessionlessSubscriber.php \Drupal\big_pipe_sessionless\EventSubscriber\HtmlResponseBigPipeSessionlessSubscriber

Response subscriber to replace the HtmlResponse with a BigPipeResponse.

Intended to replace the html_response.big_pipe_subscriber service, to use either the BigPipe service or the BigPipeSessionless service.

Hierarchy

Expanded class hierarchy of HtmlResponseBigPipeSessionlessSubscriber

See also

\Drupal\big_pipe\EventSubscriber\HtmlResponseBigPipeSubscriber

\Drupal\big_pipe_sessionless\BigPipeSessionlessServiceProvider::alter

1 file declares its use of HtmlResponseBigPipeSessionlessSubscriber
BigPipeSessionlessServiceProvider.php in src/BigPipeSessionlessServiceProvider.php

File

src/EventSubscriber/HtmlResponseBigPipeSessionlessSubscriber.php, line 20

Namespace

Drupal\big_pipe_sessionless\EventSubscriber
View source
class HtmlResponseBigPipeSessionlessSubscriber extends HtmlResponseBigPipeSubscriber {

  /**
   * The BigPipeSessionless service.
   *
   * @var \Drupal\big_pipe_sessionless\Render\BigPipeSessionless
   */
  protected $bigPipeSessionless;

  /**
   * The session configuration.
   *
   * @var \Drupal\Core\Session\SessionConfigurationInterface
   */
  protected $sessionConfiguration;

  /**
   * Constructs a HtmlResponseBigPipeSessionlessSubscriber object.
   *
   * @param \Drupal\big_pipe\Render\BigPipe $big_pipe
   *   The BigPipe service.
   * @param \Drupal\big_pipe_sessionless\Render\BigPipeSessionless $big_pipe_sessionless
   *   The BigPipeSessionless service.
   * @param \Drupal\Core\Session\SessionConfigurationInterface $session_configuration
   *   The session configuration.
   */
  public function __construct(BigPipe $big_pipe, BigPipeSessionless $big_pipe_sessionless, SessionConfigurationInterface $session_configuration) {
    parent::__construct($big_pipe);
    $this->bigPipeSessionless = $big_pipe_sessionless;
    $this->sessionConfiguration = $session_configuration;
  }

  /**
   * {@inheritdoc}
   */
  protected function getBigPipeService(FilterResponseEvent $event) {

    // Returns the BigPipeSessionless service for sessionless requests.
    return $this->sessionConfiguration
      ->hasSession($event
      ->getRequest()) ? $this->bigPipe : $this->bigPipeSessionless;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
HtmlResponseBigPipeSessionlessSubscriber::$bigPipeSessionless protected property The BigPipeSessionless service.
HtmlResponseBigPipeSessionlessSubscriber::$sessionConfiguration protected property The session configuration.
HtmlResponseBigPipeSessionlessSubscriber::getBigPipeService protected function Returns the BigPipe service to use to send the current response. Overrides HtmlResponseBigPipeSubscriber::getBigPipeService
HtmlResponseBigPipeSessionlessSubscriber::__construct public function Constructs a HtmlResponseBigPipeSessionlessSubscriber object. Overrides HtmlResponseBigPipeSubscriber::__construct
HtmlResponseBigPipeSubscriber::$bigPipe protected property The BigPipe service.
HtmlResponseBigPipeSubscriber::getSubscribedEvents public static function Returns an array of event names this subscriber wants to listen to.
HtmlResponseBigPipeSubscriber::onRespond public function Transforms a HtmlResponse to a BigPipeResponse.
HtmlResponseBigPipeSubscriber::onRespondEarly public function Adds markers to the response necessary for the BigPipe render strategy.