AttachmentsTrait.php 744 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Drupal\Core\Render;
  3. /**
  4. * Provides an implementation of AttachmentsInterface.
  5. *
  6. * @see \Drupal\Core\Render\AttachmentsInterface
  7. */
  8. trait AttachmentsTrait {
  9. /**
  10. * The attachments for this response.
  11. *
  12. * @var array
  13. */
  14. protected $attachments = [];
  15. /**
  16. * {@inheritdoc}
  17. */
  18. public function getAttachments() {
  19. return $this->attachments;
  20. }
  21. /**
  22. * {@inheritdoc}
  23. */
  24. public function addAttachments(array $attachments) {
  25. $this->attachments = BubbleableMetadata::mergeAttachments($this->attachments, $attachments);
  26. return $this;
  27. }
  28. /**
  29. * {@inheritdoc}
  30. */
  31. public function setAttachments(array $attachments) {
  32. $this->attachments = $attachments;
  33. return $this;
  34. }
  35. }