You are here

public function EntityMatcherDeriver::getDerivativeDefinitions in Linkit 8.4

Same name and namespace in other branches
  1. 8.5 src/Plugin/Derivative/EntityMatcherDeriver.php \Drupal\linkit\Plugin\Derivative\EntityMatcherDeriver::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/EntityMatcherDeriver.php, line 51
Contains \Drupal\linkit\Plugin\Derivative\EntityMatcherDeriver.

Class

EntityMatcherDeriver

Namespace

Drupal\linkit\Plugin\Derivative

Code

public function getDerivativeDefinitions($base_plugin_definition) {
  foreach ($this->entityManager
    ->getDefinitions() as $entity_type_id => $entity_type) {
    $has_canonical = $entity_type
      ->hasLinkTemplate('canonical');
    if ($has_canonical) {
      $this->derivatives[$entity_type_id] = $base_plugin_definition;
      $this->derivatives[$entity_type_id]['id'] = $base_plugin_definition['id'] . ':' . $entity_type_id;
      $this->derivatives[$entity_type_id]['label'] = $entity_type
        ->getLabel();
      $this->derivatives[$entity_type_id]['target_entity'] = $entity_type_id;
      $this->derivatives[$entity_type_id]['base_plugin_label'] = (string) $base_plugin_definition['label'];
    }
  }
  return parent::getDerivativeDefinitions($base_plugin_definition);
}