class VueBlockDeriver in Decoupled Blocks: Vue.js 8
Derives block plugin definitions for Vue components.
Hierarchy
- class \Drupal\Component\Plugin\Derivative\DeriverBase implements DeriverInterface
- class \Drupal\pdb\Plugin\Derivative\PdbBlockDeriver implements ContainerDeriverInterface
- class \Drupal\pdb_vue\Plugin\Derivative\VueBlockDeriver
- class \Drupal\pdb\Plugin\Derivative\PdbBlockDeriver implements ContainerDeriverInterface
Expanded class hierarchy of VueBlockDeriver
1 file declares its use of VueBlockDeriver
- VueBlockDeriverTest.php in tests/
src/ Unit/ Plugin/ Derivative/ VueBlockDeriverTest.php
File
- src/
Plugin/ Derivative/ VueBlockDeriver.php, line 13
Namespace
Drupal\pdb_vue\Plugin\DerivativeView source
class VueBlockDeriver extends PdbBlockDeriver {
/**
* Config Factory service.
*
* @var \Drupal\Core\Config\ConfigFactoryInterface
*/
protected $configFactory;
/**
* VueBlockDeriver constructor.
*
* @param \Drupal\pdb\ComponentDiscoveryInterface $component_discovery
* The component discovery service.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* Config Factory service.
*/
public function __construct(ComponentDiscoveryInterface $component_discovery, ConfigFactoryInterface $config_factory) {
parent::__construct($component_discovery);
$this->configFactory = $config_factory;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('pdb.component_discovery'), $container
->get('config.factory'));
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
$definitions = parent::getDerivativeDefinitions($base_plugin_definition);
// Remove any demo components if development mode is not enabled.
$config_settings = $this->configFactory
->get('pdb_vue.settings');
if (isset($config_settings) && !$config_settings
->get('development_mode')) {
$demos = [
'ng2_example_1',
'ng2_example_2',
'ng2_example_configuration',
'ng2_example_node',
'ng2_hero',
'ng2_todo',
'react_example_1',
'react_todo',
'vue_example_1',
'vue_example_2',
'vue_example_webpack',
'vue_spa_component',
'vue_todo',
'vue3_example_1',
'vue3_spa_component',
];
foreach ($definitions as $key => $definition) {
if (in_array($key, $demos)) {
unset($definitions[$key]);
}
}
}
return array_filter($definitions, function (array $definition) {
return $definition['info']['presentation'] == 'vue';
});
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DeriverBase:: |
protected | property | List of derivative definitions. | 1 |
DeriverBase:: |
public | function |
Gets the definition of a derivative plugin. Overrides DeriverInterface:: |
|
PdbBlockDeriver:: |
protected | property | The component discovery service. | |
PdbBlockDeriver:: |
protected | function | Creates the context definitions required by a block plugin. | |
VueBlockDeriver:: |
protected | property | Config Factory service. | |
VueBlockDeriver:: |
public static | function |
Creates a new class instance. Overrides PdbBlockDeriver:: |
|
VueBlockDeriver:: |
public | function |
Gets the definition of all derivatives of a base plugin. Overrides PdbBlockDeriver:: |
|
VueBlockDeriver:: |
public | function |
VueBlockDeriver constructor. Overrides PdbBlockDeriver:: |