3 namespace Drupal\Core\Plugin\Discovery;
5 use Drupal\Component\Plugin\Discovery\DiscoveryInterface;
8 * Enables YAML discovery for plugin definitions.
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.
13 class YamlDiscoveryDecorator extends YamlDiscovery {
16 * The Discovery object being decorated.
18 * @var \Drupal\Component\Plugin\Discovery\DiscoveryInterface
23 * Constructs a YamlDiscoveryDecorator object.
25 * @param \Drupal\Component\Plugin\Discovery\DiscoveryInterface $decorated
26 * The discovery object that is being decorated.
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.
33 public function __construct(DiscoveryInterface $decorated, $name, array $directories) {
34 parent::__construct($name, $directories);
36 $this->decorated = $decorated;
42 public function getDefinitions() {
43 return parent::getDefinitions() + $this->decorated->getDefinitions();
47 * Passes through all unknown calls onto the decorated object.
49 public function __call($method, $args) {
50 return call_user_func_array([$this->decorated, $method], $args);