You are here

public function InstallablePluginBase::setConfiguration in Markdown 8.2

Sets the configuration for this plugin instance.

Parameters

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

Overrides AnnotatedPluginBase::setConfiguration

3 calls to InstallablePluginBase::setConfiguration()
CommonMark::setConfiguration in src/Plugin/Markdown/CommonMark/CommonMark.php
Sets the configuration for this plugin instance.
ExternalLinkExtension::setConfiguration in src/Plugin/Markdown/CommonMark/Extension/ExternalLinkExtension.php
Sets the configuration for this plugin instance.
PhpMarkdown::setConfiguration in src/Plugin/Markdown/PhpMarkdown/PhpMarkdown.php
Sets the configuration for this plugin instance.
3 methods override InstallablePluginBase::setConfiguration()
CommonMark::setConfiguration in src/Plugin/Markdown/CommonMark/CommonMark.php
Sets the configuration for this plugin instance.
ExternalLinkExtension::setConfiguration in src/Plugin/Markdown/CommonMark/Extension/ExternalLinkExtension.php
Sets the configuration for this plugin instance.
PhpMarkdown::setConfiguration in src/Plugin/Markdown/PhpMarkdown/PhpMarkdown.php
Sets the configuration for this plugin instance.

File

src/Plugin/Markdown/InstallablePluginBase.php, line 362

Class

InstallablePluginBase
Base class for installable plugins.

Namespace

Drupal\markdown\Plugin\Markdown

Code

public function setConfiguration(array $configuration) {

  // Filter out NULL values, they will be provided by default configuration.
  $configuration = array_filter($configuration, function ($value) {
    return $value !== NULL;
  });

  // Determine the default configuration for the plugin.
  $defaultConfiguration = $this
    ->defaultConfiguration();

  // Generate a new Config object.
  $this->config = static::createConfig($this
    ->getConfigurationName(), $defaultConfiguration, TRUE, $this
    ->getContainer());

  // Determine if there any configuration overrides. Merge defaults using
  // a union with passed configuration. This ensures that the difference in
  // overrides detected below are not different if they weren't explicitly
  // passed.
  // @todo This should be a nested union merge.
  if ($overrides = $this
    ->getConfigurationOverrides($configuration + $defaultConfiguration)) {
    $this->config
      ->setModuleOverride($overrides);
  }

  // Set all the config data as the property on the plugin.
  parent::setConfiguration($this->config
    ->get());
}