Since: 1.0
Author: Bernhard Schussek (bschussek@gmail.com)
Inheritance: extends RuntimeExceptio\RuntimeException
Exemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function getChild($relPath)
 {
     if (!$this->getRepository()) {
         throw ResourceNotFoundException::forPath($this->getRepositoryPath() . '/' . $relPath);
     }
     return $this->getRepository()->get($this->getRepositoryPath() . '/' . $relPath);
 }
Exemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function get($path)
 {
     $path = $this->sanitizePath($path);
     if (!isset($this->resources[$path])) {
         throw ResourceNotFoundException::forPath($path);
     }
     return $this->resources[$path];
 }
 /**
  * {@inheritdoc}
  */
 public function get($path)
 {
     Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
     Assert::startsWith($path, '/', 'The path %s is not absolute.');
     $path = Path::canonicalize($path);
     if (!isset($this->resources[$path])) {
         throw ResourceNotFoundException::forPath($path);
     }
     return $this->resources[$path];
 }
 /**
  * {@inheritdoc}
  */
 public function getChild($relPath)
 {
     // Use attached repository if possible
     if ($this->getRepository()) {
         return $this->getRepository()->get($this->getRepositoryPath() . '/' . $relPath);
     }
     $filesystemPath = $this->getFilesystemPath() . '/' . $relPath;
     if (!file_exists($filesystemPath)) {
         throw ResourceNotFoundException::forPath($this->getPath() . '/' . $relPath);
     }
     return is_dir($filesystemPath) ? new DirectoryResource($filesystemPath) : new FileResource($filesystemPath);
 }
Exemplo n.º 5
0
 public function getChild($relPath)
 {
     throw ResourceNotFoundException::forPath($this->getPath() . '/' . $relPath);
 }
Exemplo n.º 6
0
 /**
  * {@inheritdoc}
  */
 public function get($path)
 {
     throw ResourceNotFoundException::forPath($path);
 }
Exemplo n.º 7
0
 /**
  * {@inheritdoc}
  */
 public function hasChildren($path)
 {
     if (null === $this->json) {
         $this->load();
     }
     $path = $this->sanitizePath($path);
     $results = $this->getReferencesInDirectory($path, self::STOP_ON_FIRST);
     if (empty($results)) {
         $pathResults = $this->getReferencesForPath($path);
         if (empty($pathResults)) {
             throw ResourceNotFoundException::forPath($path);
         }
         return false;
     }
     return true;
 }
Exemplo n.º 8
0
 private function getFilesystemPath($path)
 {
     $path = $this->sanitizePath($path);
     $filesystemPath = $this->baseDir . $path;
     if (!file_exists($filesystemPath)) {
         throw ResourceNotFoundException::forPath($path);
     }
     return $filesystemPath;
 }
 /**
  * {@inheritdoc}
  */
 public function findByPath($resourcePath, $typeName = null)
 {
     if (!$this->repo->contains($resourcePath)) {
         throw ResourceNotFoundException::forPath($resourcePath);
     }
     if (null === $typeName) {
         return $this->findAllForPath($resourcePath);
     }
     return $this->findByPathAndType($resourcePath, $typeName);
 }
 private function getFilesystemPath($path)
 {
     Assert::stringNotEmpty($path, 'The path must be a non-empty string. Got: %s');
     Assert::startsWith($path, '/', 'The path %s is not absolute.');
     $path = Path::canonicalize($path);
     $filesystemPath = $this->baseDir . $path;
     if (!file_exists($filesystemPath)) {
         throw ResourceNotFoundException::forPath($path);
     }
     return $filesystemPath;
 }