6ad62c491516d1174a49b1db2274c782627985dc
[yaffs-website] / web / modules / contrib / libraries / src / ExternalLibrary / Definition / FileDefinitionDiscovery.php
1 <?php
2
3 namespace Drupal\libraries\ExternalLibrary\Definition;
4
5 use Drupal\Component\Serialization\SerializationInterface;
6 use Drupal\libraries\ExternalLibrary\Exception\LibraryDefinitionNotFoundException;
7
8 /**
9  * Provides a libraries definition discovery using PHP's native file functions.
10  *
11  * It supports either a URI with a stream wrapper, an absolute file path or a
12  * file path relative to the Drupal root as a base URI.
13  *
14  * By default YAML files are used.
15  *
16  * @see \Drupal\libraries\StreamWrapper\LibraryDefinitionsStream
17  *
18  * @ingroup libraries
19  */
20 class FileDefinitionDiscovery extends FileDefinitionDiscoveryBase implements DefinitionDiscoveryInterface {
21
22   /**
23    * {@inheritdoc}
24    */
25   public function hasDefinition($id) {
26     return file_exists($this->getFileUri($id));
27   }
28
29   /**
30    * {@inheritdoc}
31    */
32   protected function getSerializedDefinition($id) {
33     return file_get_contents($this->getFileUri($id));
34   }
35
36 }