3 namespace Drupal\entity\Plugin\Derivative;
5 use Drupal\Component\Plugin\Derivative\DeriverBase;
6 use Drupal\Core\Entity\EntityTypeManagerInterface;
7 use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
8 use Symfony\Component\DependencyInjection\ContainerInterface;
11 * Provides local tasks for the revision overview.
13 class RevisionsOverviewDeriver extends DeriverBase implements ContainerDeriverInterface {
16 * The entity type manager.
18 * @var \Drupal\Core\Entity\EntityTypeManagerInterface
20 protected $entityTypeManager;
23 * Creates a new RevisionsOverviewDeriver instance.
25 * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
26 * The entity type manager.
28 public function __construct(EntityTypeManagerInterface $entityTypeManager) {
29 $this->entityTypeManager = $entityTypeManager;
35 public static function create(ContainerInterface $container, $base_plugin_id) {
37 $container->get('entity_type.manager')
44 public function getDerivativeDefinitions($base_plugin_definition) {
47 $this->derivatives = [];
48 foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
49 if (in_array($entity_type_id, $exclude)) {
53 if (!$entity_type->hasLinkTemplate('version-history')) {
57 $this->derivatives[$entity_type_id] = [
58 'route_name' => "entity.$entity_type_id.version_history",
59 'title' => t('Revisions'),
60 'base_route' => "entity.$entity_type_id.canonical",
62 ] + $base_plugin_definition;
65 return parent::getDerivativeDefinitions($base_plugin_definition);