You are here

public static function SplitFilter::create in Configuration Split 8

Creates an instance of the plugin.

Parameters

\Symfony\Component\DependencyInjection\ContainerInterface $container: The container to pull out services used in the plugin.

array $configuration: A configuration array containing information about the plugin instance.

string $plugin_id: The plugin ID for the plugin instance.

mixed $plugin_definition: The plugin implementation definition.

Return value

static Returns an instance of this plugin.

Overrides ContainerFactoryPluginInterface::create

2 calls to SplitFilter::create()
ConfigSplitKernelTest::testSerialisation in tests/src/Kernel/ConfigSplitKernelTest.php
Test that splits can be serialized.
SplitFilterTest::testSplitFilterCreate in src/Tests/SplitFilterTest.php
Test that the static create method works and folders contain the htaccess.

File

src/Plugin/ConfigFilter/SplitFilter.php, line 76

Class

SplitFilter
Provides a SplitFilter.

Namespace

Drupal\config_split\Plugin\ConfigFilter

Code

public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {

  // Get the configuration including overrides.

  /** @var \Drupal\Core\Config\ImmutableConfig $config */
  $config = $container
    ->get('config.factory')
    ->get($configuration['config_name']);

  // Transfer the configuration values to the configuration array.
  $fields = [
    'module',
    'theme',
    'blacklist',
    'graylist',
    'graylist_dependents',
    'graylist_skip_equal',
  ];
  foreach ($fields as $field) {
    $configuration[$field] = $config
      ->get($field);
  }
  return new static($configuration, $plugin_id, $plugin_definition, $container
    ->get('config.manager'), self::getSecondaryStorage($config, $container
    ->get('database')));
}