public function MockLayoutBlockDeriver::getDerivativeDefinitions

Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinitions().

Overrides DerivativeInterface::getDerivativeDefinitions

1 call to MockLayoutBlockDeriver::getDerivativeDefinitions()
MockLayoutBlockDeriver::getDerivativeDefinition in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php
Implements Drupal\Component\Plugin\Derivative\DerivativeInterface::getDerivativeDefinition().

File

drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockLayoutBlockDeriver.php, line 32
Definition of Drupal\plugin_test\Plugin\plugin_test\mock_block\MockLayoutBlockDeriver.

Class

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

Namespace

Drupal\plugin_test\Plugin\plugin_test\mock_block

Code

public function getDerivativeDefinitions(array $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['derivative']);
  $derivatives = array(
    // Adding a NULL 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.
    NULL => $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 config() object.
    'foo' => array(
      'label' => 'Layout Foo',
    ) + $base_plugin_definition,
  );
  return $derivatives;
}