You are here

public function EntityActionsDeriver::getDerivativeDefinitions in Entity API 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 DeriverBase::getDerivativeDefinitions

See also

getDerivativeDefinition()

File

src/Plugin/Derivative/EntityActionsDeriver.php, line 42

Class

EntityActionsDeriver
Derives local actions for entity types.

Namespace

Drupal\entity\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  if (!$this->derivatives) {
    foreach ($this->entityTypeManager
      ->getDefinitions() as $entity_type_id => $entity_type) {
      $handlers = $entity_type
        ->getHandlerClasses();
      if (isset($handlers['local_action_provider'])) {
        foreach ($handlers['local_action_provider'] as $class) {

          /** @var \Drupal\entity\Menu\EntityLocalActionProviderInterface $handler */
          $handler = $this->entityTypeManager
            ->createHandlerInstance($class, $entity_type);
          $this->derivatives += $handler
            ->buildLocalActions($entity_type);
        }
      }
    }
  }
  return $this->derivatives;
}