You are here

protected function BlazyManagerBase::setAttachments in Blazy 8.2

Provides attachments and cache common for all blazy-related modules.

2 calls to BlazyManagerBase::setAttachments()
BlazyManager::build in src/BlazyManager.php
Returns the contents using theme_field(), or theme_item_list().
BlazyManager::preRenderBuild in src/BlazyManager.php
Builds the Blazy outputs as a structured array ready for ::renderer().

File

src/BlazyManagerBase.php, line 416

Class

BlazyManagerBase
Implements BlazyManagerInterface.

Namespace

Drupal\blazy

Code

protected function setAttachments(array &$element, array $settings, array $attachments = []) {
  $cache = $this
    ->getCacheMetadata($settings);
  $attached = $this
    ->attach($settings);
  $attachments = empty($attachments) ? $attached : NestedArray::mergeDeep($attached, $attachments);
  $element['#attached'] = empty($element['#attached']) ? $attachments : NestedArray::mergeDeep($element['#attached'], $attachments);
  $element['#cache'] = empty($element['#cache']) ? $cache : NestedArray::mergeDeep($element['#cache'], $cache);
}