You are here

public function AccordionMenusBlock::getDerivativeDefinitions in Accordion Menus 8

Same name and namespace in other branches
  1. 8.4 src/Plugin/Derivative/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock::getDerivativeDefinitions()
  2. 8.2 src/Plugin/Derivative/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock::getDerivativeDefinitions()
  3. 8.3 src/Plugin/Derivative/AccordionMenusBlock.php \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock::getDerivativeDefinitions()

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 DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/AccordionMenusBlock.php, line 51
Contains \Drupal\accordion_menus\Plugin\Derivative\AccordionMenusBlock.

Class

AccordionMenusBlock
Provides block plugin definitions for accordion menus.

Namespace

Drupal\accordion_menus\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {

  // Get menus from accordion configuration.
  $accordion_menus = \Drupal::config('accordion_menus.settings')
    ->get('accordion_menus');
  foreach ($this->menuStorage
    ->loadMultiple() as $menu => $entity) {
    if (in_array($menu, $accordion_menus, true)) {
      $this->derivatives[$menu] = $base_plugin_definition;
      $this->derivatives[$menu]['admin_label'] = t('Accordion ') . $entity
        ->label();
      $this->derivatives[$menu]['config_dependencies']['config'] = [
        $entity
          ->getConfigDependencyName(),
      ];
    }
  }
  return $this->derivatives;
}