diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php new file mode 100644 index 0000000..872b6e2 --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscovery.php @@ -0,0 +1,64 @@ +discovery = new DrupalYamlDiscovery($name, $directories); + } + + /** + * {@inheritdoc} + */ + public function getDefinition($plugin_id) { + $definitions = $this->getDefinitions(); + return isset($definitions[$plugin_id]) ? $definitions[$plugin_id] : NULL; + } + + /** + * {@inheritdoc} + */ + public function getDefinitions() { + $plugins = $this->discovery->findAll(); + + // Flatten definitions into what's expected from plugins. + $definitions = array(); + foreach ($plugins as $provider => $list) { + foreach ($list as $id => $tmp) { + $definitions[$id] = $tmp + array( + 'provider' => $provider, + ); + } + } + + return $definitions; + } +} diff --git a/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php new file mode 100644 index 0000000..df973f5 --- /dev/null +++ b/core/lib/Drupal/Core/Plugin/Discovery/YamlDiscoveryDecorator.php @@ -0,0 +1,50 @@ +decorated = $decorated; + } + + /** + * {@inheritdoc} + */ + public function getDefinitions() { + return $this->getDefinitions() + $this->decorated->getDefinitions(); + } + + /** + * Passes through all unknown calls onto the decorated object + */ + public function __call($method, $args) { + return call_user_func_array(array($this->decorated, $method), $args); + } + +}