You are here

public function MenuLinkContentDeriver::getDerivativeDefinitions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php \Drupal\menu_link_content\Plugin\Deriver\MenuLinkContentDeriver::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

core/modules/menu_link_content/src/Plugin/Deriver/MenuLinkContentDeriver.php, line 59

Class

MenuLinkContentDeriver
Provides a deriver for user entered paths of menu links.

Namespace

Drupal\menu_link_content\Plugin\Deriver

Code

public function getDerivativeDefinitions($base_plugin_definition) {

  // Get all custom menu links which should be rediscovered.
  $entity_ids = $this->entityTypeManager
    ->getStorage('menu_link_content')
    ->getQuery()
    ->accessCheck(FALSE)
    ->condition('rediscover', TRUE)
    ->execute();
  $plugin_definitions = [];
  $menu_link_content_entities = $this->entityTypeManager
    ->getStorage('menu_link_content')
    ->loadMultiple($entity_ids);

  /** @var \Drupal\menu_link_content\MenuLinkContentInterface $menu_link_content */
  foreach ($menu_link_content_entities as $menu_link_content) {
    $plugin_definitions[$menu_link_content
      ->uuid()] = $menu_link_content
      ->getPluginDefinition();
  }
  return $plugin_definitions;
}