Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / entity / src / Plugin / Derivative / RevisionsOverviewDeriver.php
1 <?php
2
3 namespace Drupal\entity\Plugin\Derivative;
4
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;
9
10 /**
11  * Provides local tasks for the revision overview.
12  */
13 class RevisionsOverviewDeriver extends DeriverBase implements ContainerDeriverInterface {
14
15   /**
16    * The entity type manager.
17    *
18    * @var \Drupal\Core\Entity\EntityTypeManagerInterface
19    */
20   protected $entityTypeManager;
21
22   /**
23    * Creates a new RevisionsOverviewDeriver instance.
24    *
25    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
26    *   The entity type manager.
27    */
28   public function __construct(EntityTypeManagerInterface $entityTypeManager) {
29     $this->entityTypeManager = $entityTypeManager;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public static function create(ContainerInterface $container, $base_plugin_id) {
36     return new static(
37       $container->get('entity_type.manager')
38     );
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   public function getDerivativeDefinitions($base_plugin_definition) {
45     $exclude = ['node'];
46
47     $this->derivatives = [];
48     foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
49       if (in_array($entity_type_id, $exclude)) {
50         continue;
51       }
52
53       if (!$entity_type->hasLinkTemplate('version-history')) {
54         continue;
55       }
56
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",
61         'weight' => 20,
62       ] + $base_plugin_definition;
63     }
64
65     return parent::getDerivativeDefinitions($base_plugin_definition);
66   }
67
68 }