You are here

trait AttachmentsTrait in Drupal 8

Same name and namespace in other branches
  1. 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

Namesort descending Modifiers Type Description Overrides
AttachmentsTrait::$attachments protected property The attachments for this response.
AttachmentsTrait::addAttachments public function
AttachmentsTrait::getAttachments public function
AttachmentsTrait::setAttachments public function