You are here

protected function GridStackManager::prepareBuild in GridStack 8.2

Prepares GridStack build.

1 call to GridStackManager::prepareBuild()
GridStackManager::preRenderGridStack in src/GridStackManager.php

File

src/GridStackManager.php, line 249

Class

GridStackManager
Implements GridStackManagerInterface.

Namespace

Drupal\gridstack

Code

protected function prepareBuild(array &$build, array &$element) {

  // Just in case removed or changed to data-layout-builder-BLAH.
  $id1 = 'data-layout-update-url';
  $id2 = 'data-layout-builder-highlight-id';
  $settings =& $build['settings'];

  // Provides layout editor settings.
  $settings['_lb'] = isset($element['#attributes']) && (isset($element['#attributes'][$id1]) || isset($element['#attributes'][$id2]));
  $settings['_lbux'] = $settings['_lb'] && $this->moduleHandler
    ->moduleExists('lb_ux');
  $settings['_panels'] = isset($element['#prefix']) && strpos($element['#prefix'], 'panels-ipe-content') !== FALSE;
  $settings['_ipe'] = $settings['_lb'] || $settings['_lbux'] || $settings['_panels'];

  // Supports Blazy multi-breakpoint images if provided.
  if (!empty($settings['check_blazy']) && !empty($build['items'][0])) {
    $this
      ->isBlazy($settings, $build['items'][0]);
  }

  // Provides the optionset if empty. GridStackLayout, or GridStackViews, may
  // already set this. GridStackFormatter used to set it, too.
  if (empty($build['optionset'])) {
    $build['optionset'] = GridStack::loadWithFallback($settings['optionset']);
  }
  $this->optionset = $build['optionset'];

  // Prepares the settings.
  $this
    ->prepareSettings($settings);
  $this
    ->initEngine($build, $element);
}