function MockLayoutBlockDeriver::getDerivativeDefinitions

Same name and namespace in other branches
  1. 11.x core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver::getDerivativeDefinitions()
  2. 10 core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver::getDerivativeDefinitions()
  3. 9 core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver::getDerivativeDefinitions()
  4. 8.9.x core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver::getDerivativeDefinitions()

Gets the definition of all derivatives of a base plugin.

Parameters

array|\Drupal\Component\Plugin\Definition\PluginDefinitionInterface $base_plugin_definition: The definition of the base plugin from which the derivative plugin is derived. It is maybe an entire object or just some array, depending on the discovery mechanism.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides DeriverInterface::getDerivativeDefinitions

1 call to MockLayoutBlockDeriver::getDerivativeDefinitions()
MockLayoutBlockDeriver::getDerivativeDefinition in core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
Gets the definition of a derivative plugin.

File

core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php, line 33

Class

MockLayoutBlockDeriver
Mock implementation of DeriverInterface for the mock layout block plugin.

Namespace

Drupal\plugin_test\Plugin\plugin_test\mock_block

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  // This isn't strictly necessary, but it helps reduce clutter in
  // DerivativePluginTest::testDerivativeDecorator()'s $expected variable.
  // Since derivative definitions don't need further deriving, we remove this
  // key from the returned definitions.
  unset($base_plugin_definition['deriver']);
  $derivatives = [
    // Adding an empty string key signifies that the base plugin may also be
    // used in addition to the derivatives. In this case, we allow the
    // administrator to add a generic layout block to the page.
'' => $base_plugin_definition,
    // We also allow them to add a customized one. Here, we just mock the
    // customized one, but in a real implementation, this would be fetched
    // from some \Drupal::config() object.
'foo' => [
      'label' => $this->t('Layout Foo'),
    ] + $base_plugin_definition,
  ];
  return $derivatives;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.