AttachmentsResponseProcessorInterface should document the format for the different types of attachment

Created on 29 January 2024, 11 months ago
Updated 14 February 2024, 10 months ago

Problem/Motivation

The docs for AttachmentsResponseProcessorInterface::processAttachments() outline the different types that can be used in the #attached property of a render array:

   * The available keys are:
   * - 'library' (asset libraries)
   * - 'drupalSettings' (JavaScript settings)
   * - 'feed' (RSS feeds)
   * - 'html_head' (tags in HTML <head>)
   * - 'html_head_link' (<link> tags in HTML <head>)
   * - 'http_header' (HTTP headers and status code)

However, it doesn't tell you the different format, and AFAICT that's not explained anywhere else in core.

For example, at html_head item needs to be a numeric array [$data, $key], as it's processed like this:

  protected function processHtmlHead(array $html_head) {
    $head = [];
    foreach ($html_head as $item) {
      [$data, $key] = $item;
      if (!isset($data['#type'])) {
        $data['#type'] = 'html_tag';
      }
      $head[$key] = $data;
    }
    return $head;
  }

Steps to reproduce

Check the documentation of AttachmentsResponseProcessorInterface::processAttachments()

Proposed resolution

Update the documentation

Merge request link

6433

Remaining tasks

Review the changes.
Merge

User interface changes

None

API changes

None

Data model changes

None

Release notes snippet

๐Ÿ› Bug report
Status

Needs work

Version

11.0 ๐Ÿ”ฅ

Component
Documentationย  โ†’

Last updated 1 day ago

No maintainer
Created by

๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom joachim

Live updates comments and jobs are added and updated live.
  • Documentation

    Primarily changes documentation, not code. For Drupal core issues, select the Documentation component instead of using this tag. In general, component selection is preferred over tag selection.

Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024