entityTypeManager = $entity_type_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, $base_plugin_id) { return new static( $container->get('entity_type.manager') ); } /** * {@inheritdoc} */ public function getDerivativeDefinitions($base_plugin_definition) { $this->derivatives = []; foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) { // Special handling of Taxonomy. See https://www.drupal.org/node/2822546 if ($entity_type_id == "taxonomy_vocabulary") { $base_route = "entity.{$entity_type_id}.overview_form"; } else { $base_route = "entity.{$entity_type_id}.edit_form"; } if ($entity_type->hasLinkTemplate('metadata-profile')) { $this->derivatives["$entity_type_id.metadata_profile_tab"] = [ 'route_name' => "entity.{$entity_type_id}.metadata_profile", 'title' => $this->t('Metadata Profile'), 'base_route' => $base_route, 'weight' => 100, ]; } } foreach ($this->derivatives as &$entry) { $entry += $base_plugin_definition; } return $this->derivatives; } }