3 namespace Drupal\plugin_test\Plugin\plugin_test\mock_block;
5 use Drupal\Component\Plugin\Derivative\DeriverInterface;
8 * Mock implementation of DeriverInterface for the mock menu block plugin.
10 * @see \Drupal\plugin_test\Plugin\MockBlockManager
12 class MockMenuBlockDeriver implements DeriverInterface {
17 public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
18 $derivatives = $this->getDerivativeDefinitions($base_plugin_definition);
19 if (isset($derivatives[$derivative_id])) {
20 return $derivatives[$derivative_id];
27 public function getDerivativeDefinitions($base_plugin_definition) {
28 // This isn't strictly necessary, but it helps reduce clutter in
29 // DerivativePluginTest::testDerivativeDecorator()'s $expected variable.
30 // Since derivative definitions don't need further deriving, we remove this
31 // key from the returned definitions.
32 unset($base_plugin_definition['deriver']);
34 // Here, we create some mock menu block definitions for menus that might
35 // exist in a typical Drupal site. In a real implementation, we would query
36 // Drupal's configuration to find out which menus actually exist.
39 'label' => t('Main menu'),
40 ] + $base_plugin_definition,
42 'label' => t('Navigation'),
43 ] + $base_plugin_definition,
45 // Instead of the derivative label, the specific label will be used.
46 'label' => t('Derivative label'),
47 // This setting will be merged in.
48 'setting' => 'default'
49 ] + $base_plugin_definition,