trait AttachmentsTrait

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Render/AttachmentsTrait.php \Drupal\Core\Render\AttachmentsTrait
  2. 10 core/lib/Drupal/Core/Render/AttachmentsTrait.php \Drupal\Core\Render\AttachmentsTrait
  3. 11.x 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

Title Sort descending Modifiers Object type Summary
AttachmentsTrait::$attachments protected property The attachments for this response.
AttachmentsTrait::addAttachments public function
AttachmentsTrait::getAttachments public function
AttachmentsTrait::setAttachments public function

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.