Open Data Catalog v2.0.0
Sae.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use Contracts\FactoryInterface;
8 use Sae\Sae as Engine;
9 
13 class Sae implements FactoryInterface {
14 
20  private $engines = [];
21 
27  private $storage;
28 
34  private $schemaRetriever;
35 
44  public function __construct(SchemaRetriever $schemaRetriever, Data $storage) {
45  $this->schemaRetriever = $schemaRetriever;
46  $this->storage = $storage;
47  }
48 
52  public function getInstance(string $identifier, array $config = []) {
53  if (!isset($this->engines[$identifier])) {
54  $this->engines[$identifier] = new Engine($this->getStorage($identifier), $this->getJsonSchema($identifier));
55  }
56  return $this->engines[$identifier];
57  }
58 
65  private function getJsonSchema($schema_id) {
66 
67  // @Todo: mechanism to validate against additional schemas. For now,
68  // validate against the empty object, as it accepts any valid json.
69  if ($schema_id != 'dataset') {
70  return '{ }';
71  }
72 
73  return $this->schemaRetriever->retrieve('dataset');
74  }
75 
82  private function getStorage($schema_id) {
83  $this->storage->setSchema($schema_id);
84  return $this->storage;
85  }
86 
87 }
Drupal\dkan_data\Storage\Data
Definition: Data.php:16
Drupal\dkan_metastore\Factory\Sae
Definition: Sae.php:13
Drupal\dkan_metastore\Factory\Sae\getInstance
getInstance(string $identifier, array $config=[])
Definition: Sae.php:52
Drupal\dkan_schema\SchemaRetriever
Definition: SchemaRetriever.php:11
Drupal\dkan_metastore\Factory
Definition: Sae.php:3
Drupal\dkan_metastore\Factory\Sae\__construct
__construct(SchemaRetriever $schemaRetriever, Data $storage)
Definition: Sae.php:44