Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Plugin / Discovery / ContainerDerivativeDiscoveryDecorator.php
1 <?php
2
3 namespace Drupal\Core\Plugin\Discovery;
4
5 use Drupal\Component\Plugin\Discovery\DerivativeDiscoveryDecorator;
6
7 class ContainerDerivativeDiscoveryDecorator extends DerivativeDiscoveryDecorator {
8
9   /**
10    * {@inheritdoc}
11    */
12   protected function getDeriver($base_plugin_id, $base_definition) {
13     if (!isset($this->derivers[$base_plugin_id])) {
14       $this->derivers[$base_plugin_id] = FALSE;
15       $class = $this->getDeriverClass($base_definition);
16       if ($class) {
17         // If the deriver provides a factory method, pass the container to it.
18         if (is_subclass_of($class, '\Drupal\Core\Plugin\Discovery\ContainerDeriverInterface')) {
19           /** @var \Drupal\Core\Plugin\Discovery\ContainerDeriverInterface $class */
20           $this->derivers[$base_plugin_id] = $class::create(\Drupal::getContainer(), $base_plugin_id);
21         }
22         else {
23           $this->derivers[$base_plugin_id] = new $class($base_plugin_id);
24         }
25       }
26     }
27     return $this->derivers[$base_plugin_id] ?: NULL;
28   }
29
30 }