You are here

public function ComponentBlock::setConfiguration in Component blocks 1.1.x

Same name and namespace in other branches
  1. 1.x src/Plugin/Block/ComponentBlock.php \Drupal\component_blocks\Plugin\Block\ComponentBlock::setConfiguration()
  2. 1.0.x src/Plugin/Block/ComponentBlock.php \Drupal\component_blocks\Plugin\Block\ComponentBlock::setConfiguration()

Overrides BlockPluginTrait::setConfiguration

File

src/Plugin/Block/ComponentBlock.php, line 152

Class

ComponentBlock
Defines a class for a specially shaped block.

Namespace

Drupal\component_blocks\Plugin\Block

Code

public function setConfiguration(array $configuration) {
  $defaultConfiguration = $this
    ->defaultConfiguration();
  $plugin = $this
    ->uiPatternsManager()
    ->getDefinition($this->pluginDefinition['ui_pattern_id']);
  foreach ($plugin['fields'] as $item) {
    if (!($item['ui'] ?? TRUE)) {

      // We don't want duplicates for no-ui items - default is enough.
      unset($configuration['variables'][$item
        ->getName()]['value']);
    }
  }
  $this->configuration = NestedArray::mergeDeep($this
    ->baseConfigurationDefaults(), $defaultConfiguration, $configuration);
}