pathToConfigFilesRequired() public static method

public static pathToConfigFilesRequired ( )
Exemplo n.º 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);
 }
Exemplo n.º 2
0
 /**
  * Get all the metadata class names known to this driver.
  * @throws DrestException
  * @return array          $classes
  */
 public function getAllClassNames()
 {
     if (empty($this->classNames)) {
         if (empty($this->paths)) {
             throw DrestException::pathToConfigFilesRequired();
         }
         $classes = [];
         $included = [];
         foreach ($this->paths as $path) {
             $iterator = new \RecursiveIteratorIterator(new \RecursiveDirectoryIterator($path, \FilesystemIterator::SKIP_DOTS), \RecursiveIteratorIterator::LEAVES_ONLY);
             foreach ($iterator as $file) {
                 /* @var \SplFileInfo $file */
                 if (!in_array($file->getExtension(), $this->extensions)) {
                     continue;
                 }
                 $path = $file->getRealPath();
                 if (!empty($path)) {
                     require_once $path;
                 }
                 // Register the files we've included here
                 $included[] = $path;
             }
         }
         foreach (get_declared_classes() as $className) {
             $reflClass = new \ReflectionClass($className);
             $sourceFile = $reflClass->getFileName();
             if (in_array($sourceFile, $included) && $this->isDrestResource($className)) {
                 $classes[] = $className;
             }
         }
         $this->classNames = $classes;
     }
     return $this->classNames;
 }
Exemplo n.º 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();
         }
         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);
 }
Exemplo n.º 4
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);
 }