Open Data Catalog v2.0.0
DatastoreQuery.php
Go to the documentation of this file.
1 <?php
2 
4 
5 use RootedData\RootedJsonData;
6 
10 class DatastoreQuery extends RootedJsonData {
11 
18  public function __construct(string $json) {
19  $schema = file_get_contents(__DIR__ . "/../../docs/query.json");
20  parent::__construct($json, $schema);
21  $this->populateDefaults();
22  }
23 
27  private function populateDefaults() {
28  $schemaJson = new RootedJsonData($this->getSchema());
29  $properties = $schemaJson->{"$.properties"};
30  foreach ($properties as $key => $property) {
31  if (isset($property['default']) && !isset($this->{"$.$key"})) {
32  $this->{"$.$key"} = $property['default'];
33  }
34  }
35  }
36 
37 }
Drupal\datastore\Service\DatastoreQuery
Definition: DatastoreQuery.php:10
Drupal\datastore\Service
Definition: DatastoreQuery.php:3
Drupal\datastore\Service\DatastoreQuery\__construct
__construct(string $json)
Definition: DatastoreQuery.php:18