You are here

public function BlazyManagerBase::getCommonSettings in Blazy 8.2

Same name and namespace in other branches
  1. 8 src/BlazyManagerBase.php \Drupal\blazy\BlazyManagerBase::getCommonSettings()
  2. 7 src/BlazyManagerBase.php \Drupal\blazy\BlazyManagerBase::getCommonSettings()

Returns the common UI settings inherited down to each item.

The `fx` sequence: hook_alter > formatters (not implemented yet) > UI. The `_fx` is a special flag such as to temporarily disable till needed.

1 call to BlazyManagerBase::getCommonSettings()
BlazyFormatter::buildSettings in src/BlazyFormatter.php
Modifies the field formatter settings inherited by child elements.

File

src/BlazyManagerBase.php, line 289

Class

BlazyManagerBase
Implements BlazyManagerInterface.

Namespace

Drupal\blazy

Code

public function getCommonSettings(array &$settings) {
  $config = array_intersect_key($this
    ->configLoad(), BlazyDefault::uiSettings());
  $config['fx'] = isset($config['fx']) ? $config['fx'] : '';
  $config['fx'] = empty($settings['fx']) ? $config['fx'] : $settings['fx'];
  $settings = array_merge($settings, $config);
  $settings['fx'] = isset($settings['_fx']) ? $settings['_fx'] : $settings['fx'];
  $settings['media_switch'] = $switch = empty($settings['media_switch']) ? '' : $settings['media_switch'];
  $settings['iframe_domain'] = $this
    ->configLoad('iframe_domain', 'media.settings');
  $settings['is_preview'] = Blazy::isPreview();
  $settings['lightbox'] = $switch && in_array($switch, $this
    ->getLightboxes()) ? $switch : FALSE;
  $settings['namespace'] = empty($settings['namespace']) ? 'blazy' : $settings['namespace'];
  $settings['route_name'] = Blazy::routeMatch() ? Blazy::routeMatch()
    ->getRouteName() : '';
  $settings['_resimage'] = $this->moduleHandler
    ->moduleExists('responsive_image');
  $settings['resimage'] = $settings['_resimage'] && !empty($settings['responsive_image_style']);
  $settings['resimage'] = $settings['resimage'] ? $this
    ->entityLoad($settings['responsive_image_style'], 'responsive_image_style') : FALSE;
  $settings['current_language'] = $this->languageManager
    ->getCurrentLanguage()
    ->getId();
  if ($switch) {

    // Allows lightboxes to provide its own optionsets, e.g.: ElevateZoomPlus.
    $settings[$switch] = empty($settings[$switch]) ? $switch : $settings[$switch];
  }
}