You are here

public function Builder::adminAttributes in GridStack 8.2

Provides Layout Builder attributes if available.

GridStackLayout has no knowledge of IPE, and IPE expects region keys which are not provided by GridStack, hence rebuild needed attributes. Must use $content_attributes for draggable to work, not $attributes.

Parameters

array $box: The box being modified.

array $content_attributes: The content attributes being modified.

array $settings: The settings.

array $regions: The region attributes provided by Layout Builder for admin.

File

src/Plugin/gridstack/stylizer/Builder.php, line 75

Class

Builder
Provides Layout Builder integration for editor previews.

Namespace

Drupal\gridstack\Plugin\gridstack\stylizer

Code

public function adminAttributes(array &$box, array &$content_attributes, array $settings, array $regions = []) {
  $rid = isset($settings['rid']) ? $settings['rid'] : -1;
  $region = isset($regions[$rid]) ? $regions[$rid] : [];

  // Layout Builder integration.
  if (!empty($region['#attributes']) && is_array($region['#attributes'])) {
    $this
      ->lb($box, $content_attributes, $settings, $region);
  }

  // Panels IPE integration.
  if (!empty($settings['_panels']) && !empty($region['#prefix'])) {
    $this
      ->panels($box, $settings, $region);
  }
}