예제 #1
0
파일: JsonDriver.php 프로젝트: jdrich/drest
 /**
  * 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);
 }
예제 #2
0
파일: PhpDriver.php 프로젝트: nuxwin/drest
 /**
  * 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);
 }
예제 #3
0
파일: YamlDriver.php 프로젝트: jdrich/drest
 /**
  * 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);
 }