You are here

public function VueBlockDeriver::getDerivativeDefinitions in Decoupled Blocks: Vue.js 8

Gets the definition of all derivatives of a base plugin.

Parameters

array $base_plugin_definition: The definition array of the base plugin.

Return value

array An array of full derivative definitions keyed on derivative id.

Overrides PdbBlockDeriver::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/VueBlockDeriver.php, line 48

Class

VueBlockDeriver
Derives block plugin definitions for Vue components.

Namespace

Drupal\pdb_vue\Plugin\Derivative

Code

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';
  });
}