class MockMenuBlockDeriver in Drupal 10
Same name and namespace in other branches
- 8 core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlockDeriver
- 9 core/modules/system/tests/modules/plugin_test/src/Plugin/plugin_test/mock_block/MockMenuBlockDeriver.php \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlockDeriver
Mock implementation of DeriverInterface for the mock menu block plugin.
Hierarchy
- class \Drupal\plugin_test\Plugin\plugin_test\mock_block\MockMenuBlockDeriver implements DeriverInterface
Expanded class hierarchy of MockMenuBlockDeriver
See also
\Drupal\plugin_test\Plugin\MockBlockManager
File
- core/
modules/ system/ tests/ modules/ plugin_test/ src/ Plugin/ plugin_test/ mock_block/ MockMenuBlockDeriver.php, line 12
Namespace
Drupal\plugin_test\Plugin\plugin_test\mock_blockView source
class MockMenuBlockDeriver implements DeriverInterface {
/**
* {@inheritdoc}
*/
public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
$derivatives = $this
->getDerivativeDefinitions($base_plugin_definition);
if (isset($derivatives[$derivative_id])) {
return $derivatives[$derivative_id];
}
}
/**
* {@inheritdoc}
*/
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']);
// 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 = [
'main_menu' => [
'label' => t('Main menu'),
] + $base_plugin_definition,
'navigation' => [
'label' => t('Navigation'),
] + $base_plugin_definition,
'foo' => [
// Instead of the derivative label, the specific label will be used.
'label' => t('Derivative label'),
// This setting will be merged in.
'setting' => 'default',
] + $base_plugin_definition,
];
return $derivatives;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MockMenuBlockDeriver:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
MockMenuBlockDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides DeriverInterface:: |