3 namespace Drupal\Core\Render;
6 * Defines an interface for processing attachments of responses that have them.
8 * @see \Drupal\Core\Ajax\AjaxResponse
9 * @see \Drupal\Core\Ajax\AjaxResponseAttachmentsProcessor
10 * @see \Drupal\Core\Render\HtmlResponse
11 * @see \Drupal\Core\Render\HtmlResponseAttachmentsProcessor
13 interface AttachmentsResponseProcessorInterface {
16 * Processes the attachments of a response that has attachments.
18 * Libraries, JavaScript settings, feeds, HTML <head> tags, HTML <head> links,
19 * HTTP headers, and the HTTP status code are attached to render arrays using
20 * the #attached property. The #attached property is an associative array,
21 * where the keys are the attachment types and the values are the attached
25 * $build['#attached']['library'][] = [
26 * 'library' => ['core/jquery']
28 * $build['#attached']['http_header'] = [
29 * ['Content-Type', 'application/rss+xml; charset=utf-8'],
33 * The available keys are:
34 * - 'library' (asset libraries)
35 * - 'drupalSettings' (JavaScript settings)
36 * - 'feed' (RSS feeds)
37 * - 'html_head' (tags in HTML <head>)
38 * - 'html_head_link' (<link> tags in HTML <head>)
39 * - 'http_header' (HTTP headers and status code)
41 * @param \Drupal\Core\Render\AttachmentsInterface $response
42 * The response to process.
44 * @return \Drupal\Core\Render\AttachmentsInterface
45 * The processed response, with the attachments updated to reflect their
48 * @throws \InvalidArgumentException
49 * Thrown when the $response parameter is not the type of response object
50 * the processor expects.
52 public function processAttachments(AttachmentsInterface $response);