public function MockMenuBlockDeriver::getDerivativeDefinitions

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

Overrides DerivativeInterface::getDerivativeDefinitions

1 call to MockMenuBlockDeriver::getDerivativeDefinitions()
MockMenuBlockDeriver::getDerivativeDefinition in drupal/core/modules/system/tests/modules/plugin_test/lib/Drupal/plugin_test/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.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/MockMenuBlockDeriver.php, line 32
Definition of Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlockDeriver.

Class

MockMenuBlockDeriver
Mock implementation of DerivativeInterface for the mock menu 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']);

  // Here, we create some mock menu block definitions for menus that might
  // exist in a typical Drupal site. In a real implementation, we would query
  // Drupal's configuration to find out which menus actually exist.
  $derivatives = array(
    'main_menu' => array(
      'label' => t('Main menu'),
    ) + $base_plugin_definition,
    'navigation' => array(
      'label' => t('Navigation'),
    ) + $base_plugin_definition,
  );
  return $derivatives;
}