You are here

public function ViewsSynonymsEntityArgumentValidator::getDerivativeDefinitions in Synonyms 8

Same name and namespace in other branches
  1. 2.0.x modules/synonyms_views_argument_validator/src/Plugin/Derivative/ViewsSynonymsEntityArgumentValidator.php \Drupal\synonyms_views_argument_validator\Plugin\Derivative\ViewsSynonymsEntityArgumentValidator::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

synonyms_views_argument_validator/src/Plugin/Derivative/ViewsSynonymsEntityArgumentValidator.php, line 57

Class

ViewsSynonymsEntityArgumentValidator
Provides synonyms views argument validator for all entity types.

Namespace

Drupal\synonyms_views_argument_validator\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  $entity_types = $this->entityTypeManager
    ->getDefinitions();
  $this->derivatives = [];
  foreach ($entity_types as $entity_type_id => $entity_type) {
    if ($entity_type instanceof ContentEntityTypeInterface) {
      $this->derivatives[$entity_type_id] = [
        'id' => 'synonyms_entity:' . $entity_type_id,
        'provider' => 'synonyms',
        'title' => $this
          ->t('Synonyms of @entity_type', [
          '@entity_type' => $entity_type
            ->getSingularLabel(),
        ]),
        'help' => $this
          ->t('Validate @label', [
          '@label' => $entity_type
            ->getLabel(),
        ]),
        'entity_type' => $entity_type_id,
        'class' => $base_plugin_definition['class'],
      ];
    }
  }
  return $this->derivatives;
}