diff --git a/lib/Drupal/Component/Discovery/DiscoverableInterface.php b/lib/Drupal/Component/Discovery/DiscoverableInterface.php new file mode 100644 index 0000000..c04556f --- /dev/null +++ b/lib/Drupal/Component/Discovery/DiscoverableInterface.php @@ -0,0 +1,23 @@ +name = $name; + $this->directories = $directories; + } + + /** + * {@inheritdoc} + */ + public function findAll() { + $all = array(); + foreach ($this->findFiles() as $provider => $file) { + $all[$provider] = Yaml::decode(file_get_contents($file)); + } + + return $all; + } + + /** + * Returns an array of file paths, keyed by provider. + * + * @return array + */ + protected function findFiles() { + $files = array(); + foreach ($this->directories as $provider => $directory) { + $file = $directory . '/' . $provider . '.' . $this->name . '.yml'; + if (file_exists($file)) { + $files[$provider] = $file; + } + } + return $files; + } + +} +