Beispiel #1
0
 /**
  * Get all the metadata class names known to this driver.
  * @return array
  * @throws DrestException
  * @throws DriverException
  */
 public function getAllClassNames()
 {
     if (empty($this->classes)) {
         if (empty($this->paths)) {
             throw DrestException::pathToConfigFilesRequired();
         }
         foreach ($this->paths as $path) {
             if (!file_exists($path)) {
                 throw DriverException::configurationFileDoesntExist($path);
             }
             $resources = json_decode(file_get_contents($path), true);
             if ($resources === null) {
                 throw DriverException::configurationFileIsInvalid('Json');
             }
             $entities = [];
             foreach ($resources['resources'] as $resource) {
                 $entity = $resource['entity'];
                 $entities[$entity] = $resource;
                 unset($entities[$entity]['entity']);
             }
             $this->classes = array_merge($this->classes, $entities);
         }
     }
     return array_keys($this->classes);
 }
Beispiel #2
0
 /**
  * Get all the metadata class names known to this driver.
  * @return array
  * @throws DrestException
  * @throws DriverException
  */
 public function getAllClassNames()
 {
     if (empty($this->classes)) {
         if (empty($this->paths)) {
             throw DrestException::pathToConfigFilesRequired();
         }
         foreach ($this->paths as $path) {
             if (!file_exists($path)) {
                 throw DriverException::configurationFileDoesntExist($path);
             }
             $resources = (include $path);
             if (!is_array($resources)) {
                 throw DriverException::configurationFileIsInvalid('Php');
             }
             $this->classes = array_merge($this->classes, $resources);
         }
     }
     return array_keys($this->classes);
 }
Beispiel #3
0
 /**
  * Get all the metadata class names known to this driver.
  * @return array
  * @throws DrestException
  * @throws DriverException
  */
 public function getAllClassNames()
 {
     if (empty($this->classes)) {
         if (empty($this->paths)) {
             throw DrestException::pathToConfigFilesRequired();
         }
         $yamlParser = new YamlParser();
         foreach ($this->paths as $path) {
             if (!file_exists($path)) {
                 throw DriverException::configurationFileDoesntExist($path);
             }
             $resources = $yamlParser->parse(file_get_contents($path));
             if ($resources === false || empty($resources)) {
                 throw DriverException::configurationFileIsInvalid('Yaml');
             }
             $this->classes = array_merge($this->classes, (array) $resources);
         }
     }
     return array_keys($this->classes);
 }