class HtmlResponseAttachmentsProcessor in HTTP/2 Server Push 8
Decorates the HTML response attachments processor service, adds Server Push.
Hierarchy
- class \Drupal\http2_server_push\Render\HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorInterface
Expanded class hierarchy of HtmlResponseAttachmentsProcessor
See also
\Drupal\http2_server_push\Asset\CssCollectionRenderer
\Drupal\http2_server_push\Asset\JsCollectionRenderer
1 string reference to 'HtmlResponseAttachmentsProcessor'
1 service uses HtmlResponseAttachmentsProcessor
File
- src/
Render/ HtmlResponseAttachmentsProcessor.php, line 15
Namespace
Drupal\http2_server_push\RenderView source
class HtmlResponseAttachmentsProcessor implements AttachmentsResponseProcessorInterface {
/**
* The decorated HTML response attachments processor service.
*
* @var \Drupal\Core\Render\AttachmentsResponseProcessorInterface
*/
protected $htmlResponseAttachmentsProcessor;
/**
* The request stack.
*
* @var \Symfony\Component\HttpFoundation\RequestStack
*/
protected $requestStack;
/**
* Constructs a HtmlResponseAttachmentsProcessor object.
*
* @param \Drupal\Core\Render\AttachmentsResponseProcessorInterface $html_response_attachments_processor
* The decorated HTML response attachments processor service.
* @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
* The request stack.
*/
public function __construct(AttachmentsResponseProcessorInterface $html_response_attachments_processor, RequestStack $request_stack) {
$this->htmlResponseAttachmentsProcessor = $html_response_attachments_processor;
$this->requestStack = $request_stack;
}
/**
* {@inheritdoc}
*/
public function processAttachments(AttachmentsInterface $response) {
$response = $this->htmlResponseAttachmentsProcessor
->processAttachments($response);
$request = $this->requestStack
->getCurrentRequest();
if ($request->attributes
->has('http2_server_push_link_headers')) {
$new_link_headers = $request->attributes
->get('http2_server_push_link_headers');
$existing_link_headers = $response->headers
->get('Link', NULL, FALSE);
$merged_link_headers = array_unique(array_merge($existing_link_headers, $new_link_headers));
$response->headers
->set('Link', $merged_link_headers, TRUE);
}
return $response;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
HtmlResponseAttachmentsProcessor:: |
protected | property | The decorated HTML response attachments processor service. | |
HtmlResponseAttachmentsProcessor:: |
protected | property | The request stack. | |
HtmlResponseAttachmentsProcessor:: |
public | function |
Processes the attachments of a response that has attachments. Overrides AttachmentsResponseProcessorInterface:: |
|
HtmlResponseAttachmentsProcessor:: |
public | function | Constructs a HtmlResponseAttachmentsProcessor object. |