Upgraded imagemagick and manually altered pdf to image module to handle changes....
[yaffs-website] / web / modules / contrib / entity / src / Plugin / Derivative / EntityActionsDeriver.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  * Derives local actions for entity types.
12  */
13 class EntityActionsDeriver 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    * Constructs an entity local actions deriver.
24    *
25    * @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
26    *   The entity type manager.
27    */
28   public function __construct(EntityTypeManagerInterface $entity_type_manager) {
29     $this->entityTypeManager = $entity_type_manager;
30   }
31
32   /**
33    * {@inheritdoc}
34    */
35   public static function create(ContainerInterface $container, $base_plugin_id) {
36     return new static($container->get('entity_type.manager'));
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function getDerivativeDefinitions($base_plugin_definition) {
43     if (!$this->derivatives) {
44       foreach ($this->entityTypeManager->getDefinitions() as $entity_type_id => $entity_type) {
45         $handlers = $entity_type->getHandlerClasses();
46         if (isset($handlers['local_action_provider'])) {
47           foreach ($handlers['local_action_provider'] as $class) {
48             /** @var \Drupal\entity\Menu\EntityLocalActionProviderInterface $handler */
49             $handler = $this->entityTypeManager->createHandlerInstance($class, $entity_type);
50             $this->derivatives += $handler->buildLocalActions($entity_type);
51           }
52         }
53       }
54     }
55     return $this->derivatives;
56   }
57
58 }