Upgraded drupal core with security updates
[yaffs-website] / web / core / lib / Drupal / Core / Plugin / Discovery / YamlDiscoveryDecorator.php
1 <?php
2
3 namespace Drupal\Core\Plugin\Discovery;
4
5 use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
6
7 /**
8  * Enables YAML discovery for plugin definitions.
9  *
10  * You should normally extend this class to add validation for the values in the
11  * YAML data or to restrict use of the class or derivatives keys.
12  */
13 class YamlDiscoveryDecorator extends YamlDiscovery {
14
15   /**
16    * The Discovery object being decorated.
17    *
18    * @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
19    */
20   protected $decorated;
21
22   /**
23    * Constructs a YamlDiscoveryDecorator object.
24    *
25    * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
26    *   The discovery object that is being decorated.
27    * @param string $name
28    *   The file name suffix to use for discovery; for instance, 'test' will
29    *   become 'MODULE.test.yml'.
30    * @param array $directories
31    *   An array of directories to scan.
32    */
33   public function __construct(DiscoveryInterface $decorated, $name, array $directories) {
34     parent::__construct($name, $directories);
35
36     $this->decorated = $decorated;
37   }
38
39   /**
40    * {@inheritdoc}
41    */
42   public function getDefinitions() {
43     return parent::getDefinitions() + $this->decorated->getDefinitions();
44   }
45
46   /**
47    * Passes through all unknown calls onto the decorated object.
48    */
49   public function __call($method, $args) {
50     return call_user_func_array([$this->decorated, $method], $args);
51   }
52
53 }