You are here

trait AttachmentsTrait in Drupal 10

Same name and namespace in other branches
  1. 8 core/lib/Drupal/Core/Render/AttachmentsTrait.php \Drupal\Core\Render\AttachmentsTrait
  2. 9 core/lib/Drupal/Core/Render/AttachmentsTrait.php \Drupal\Core\Render\AttachmentsTrait

Provides an implementation of AttachmentsInterface.

Hierarchy

See also

\Drupal\Core\Render\AttachmentsInterface

3 files declare their use of AttachmentsTrait
AjaxResponse.php in core/lib/Drupal/Core/Ajax/AjaxResponse.php
AttachmentsTestDomainObject.php in core/modules/system/tests/modules/early_rendering_controller_test/src/AttachmentsTestDomainObject.php
AttachmentsTestResponse.php in core/modules/system/tests/modules/early_rendering_controller_test/src/AttachmentsTestResponse.php

File

core/lib/Drupal/Core/Render/AttachmentsTrait.php, line 10

Namespace

Drupal\Core\Render
View source
trait AttachmentsTrait {

  /**
   * The attachments for this response.
   *
   * @var array
   */
  protected $attachments = [];

  /**
   * {@inheritdoc}
   */
  public function getAttachments() {
    return $this->attachments;
  }

  /**
   * {@inheritdoc}
   */
  public function addAttachments(array $attachments) {
    $this->attachments = BubbleableMetadata::mergeAttachments($this->attachments, $attachments);
    return $this;
  }

  /**
   * {@inheritdoc}
   */
  public function setAttachments(array $attachments) {
    $this->attachments = $attachments;
    return $this;
  }

}

Members