Пример #1
0
 /**
  * {@inheritdoc}
  */
 public function retrieve($uri)
 {
     if (isset($this->mappings[$uri])) {
         $uri = $this->mappings[$uri];
         if (Path::isLocal($uri)) {
             $uri = 'file://' . ($this->baseDir ? Path::makeAbsolute($uri, $this->baseDir) : $uri);
         }
         $this->lastUsedRetriever = $this->filesystemRetriever;
         return $this->filesystemRetriever->retrieve($uri);
     }
     $this->lastUsedRetriever = $this->fallbackRetriever;
     return $this->fallbackRetriever->retrieve($uri);
 }
Пример #2
0
 /**
  * Fetch a schema from the given URI, json-decode it and return it.
  * Caches schema objects.
  *
  * @param string $fetchUri Absolute URI
  *
  * @return object JSON schema object
  */
 protected function loadSchema($fetchUri)
 {
     if (isset($this->schemaCache[$fetchUri])) {
         return $this->schemaCache[$fetchUri];
     }
     $uriRetriever = $this->getUriRetriever();
     $contents = $this->uriRetriever->retrieve($fetchUri);
     $this->confirmMediaType($uriRetriever, $fetchUri);
     $jsonSchema = json_decode($contents);
     if (JSON_ERROR_NONE < ($error = json_last_error())) {
         throw new JsonDecodingException($error);
     }
     $this->schemaCache[$fetchUri] = $jsonSchema;
     return $jsonSchema;
 }