You are here

public function CivicrmEntityMenuLink::getDerivativeDefinitions in CiviCRM Entity 8.3

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/CivicrmEntityMenuLink.php, line 48

Class

CivicrmEntityMenuLink
Provides local action definitions for all CiviCRM entity definitions.

Namespace

Drupal\civicrm_entity\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $this->derivatives = [];
  $civicrm_entities = array_filter($this->entityTypeManager
    ->getDefinitions(), function (EntityTypeInterface $type) {
    return $type
      ->getProvider() == 'civicrm_entity' && $type
      ->get('civicrm_entity_ui_exposed');
  });

  /** @var \Drupal\Core\Entity\EntityTypeInterface $entity_type */
  foreach ($civicrm_entities as $entity_type_id => $entity_type) {
    $this->derivatives["field_storage_config_add_{$entity_type_id}"] = [
      'route_name' => "entity.{$entity_type_id}.collection",
      'title' => $entity_type
        ->getLabel(),
      'parent' => 'civicrm_entity.admin',
      'description' => $this
        ->t('Manage :label', [
        ':label' => $entity_type
          ->getLabel(),
      ]),
    ] + $base_plugin_definition;
  }
  return $this->derivatives;
}