public YamlDirectoryDiscovery::findAll()
Returns an array of discoverable items.
array An array of discovered data keyed by provider.
\Drupal\Component\Discovery\DiscoveryException Exception thrown if there is a problem during discovery.
Overrides DiscoverableInterface::findAll
public function findAll() { $all = array(); $files = $this->findFiles(); $file_cache = FileCacheFactory::get('yaml_discovery:' . $this->fileCacheKeySuffix); // Try to load from the file cache first. foreach ($file_cache->getMultiple(array_keys($files)) as $file => $data) { $all[$files[$file]][$this->getIdentifier($file, $data)] = $data; unset($files[$file]); } // If there are files left that were not returned from the cache, load and // parse them now. This list was flipped above and is keyed by filename. if ($files) { foreach ($files as $file => $provider) { // If a file is empty or its contents are commented out, return an empty // array instead of NULL for type consistency. try { $data = Yaml::decode(file_get_contents($file)) ? : []; } catch (InvalidDataTypeException $e) { throw new DiscoveryException("The $file contains invalid YAML", 0, $e); } $data[static::FILE_KEY] = $file; $all[$provider][$this->getIdentifier($file, $data)] = $data; $file_cache->set($file, $data); } } return $all; }
© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Component!Discovery!YamlDirectoryDiscovery.php/function/YamlDirectoryDiscovery::findAll/8.1.x