MergeLocalTask.php in Bibliography & Citation 8
File
modules/bibcite_entity/src/Plugin/Derivative/MergeLocalTask.php
View source
<?php
namespace Drupal\bibcite_entity\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DeriverBase;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class MergeLocalTask extends DeriverBase implements ContainerDeriverInterface {
protected $entityTypeManager;
public function __construct(EntityTypeManagerInterface $entity_type_manager) {
$this->entityTypeManager = $entity_type_manager;
}
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static($container
->get('entity_type.manager'));
}
public function getDerivativeDefinitions($base_plugin_definition) {
foreach ($this->entityTypeManager
->getDefinitions() as $entity_type_id => $entity_type) {
if ($entity_type
->hasLinkTemplate('bibcite-merge-form')) {
$this->derivatives["entity.{$entity_type_id}.bibcite_merge_form"] = [
'route_name' => "entity.{$entity_type_id}.bibcite_merge_form",
'base_route' => "entity.{$entity_type_id}.canonical",
] + $base_plugin_definition;
}
}
return $this->derivatives;
}
}