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 layout block plugin.
10 * @see \Drupal\plugin_test\Plugin\MockBlockManager
12 class MockLayoutBlockDeriver 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']);
35 // Adding a NULL key signifies that the base plugin may also be used in
36 // addition to the derivatives. In this case, we allow the administrator
37 // to add a generic layout block to the page.
38 NULL => $base_plugin_definition,
40 // We also allow them to add a customized one. Here, we just mock the
41 // customized one, but in a real implementation, this would be fetched
42 // from some \Drupal::config() object.
44 'label' => t('Layout Foo'),
45 ] + $base_plugin_definition,