You are here

public function PanelsDisplayVariant::setConfiguration in Panels 8.3

Same name and namespace in other branches
  1. 8.4 src/Plugin/DisplayVariant/PanelsDisplayVariant.php \Drupal\panels\Plugin\DisplayVariant\PanelsDisplayVariant::setConfiguration()

Sets the configuration for this plugin instance.

Parameters

array $configuration: An associative array containing the plugin's configuration.

Overrides BlockDisplayVariant::setConfiguration

File

src/Plugin/DisplayVariant/PanelsDisplayVariant.php, line 454

Class

PanelsDisplayVariant
Provides a display variant that simply contains blocks.

Namespace

Drupal\panels\Plugin\DisplayVariant

Code

public function setConfiguration(array $configuration) {
  if (empty($configuration['uuid'])) {
    $configuration['uuid'] = $this
      ->uuidGenerator()
      ->generate();
  }

  // Make sure blocks are mapped to valid regions, and if not, map them to the
  // first available region. This is a work-around the fact that we're not
  // totally in control of the block placement UI from page_manager.
  // @todo Replace after https://www.drupal.org/node/2550879
  if (!empty($configuration['layout']) && !empty($configuration['blocks'])) {
    $layout_definition = $this->layoutManager
      ->getDefinition($configuration['layout']);
    $valid_regions = $layout_definition['regions'];
    $first_region = array_keys($valid_regions)[0];
    foreach ($configuration['blocks'] as &$block) {
      if (!isset($valid_regions[$block['region']])) {
        $block['region'] = $first_region;
      }
    }
  }
  return parent::setConfiguration($configuration);
}