コード例 #1
0
ファイル: HttpLoader.php プロジェクト: eloquent/schemer
 /**
  * @param UriInterface $uri
  *
  * @return Content
  * @throws LoadException
  */
 public function load(UriInterface $uri)
 {
     if (!$uri instanceof HttpUriInterface) {
         throw new InvalidUriTypeException($uri, 'Eloquent\\Schemer\\Uri\\HttpUriInterface');
     }
     if (!$uri->isAbsolute()) {
         throw new RelativeUriException($uri);
     }
     $response = $this->browser()->get($uri->toString());
     if (!$response->isSuccessful()) {
         throw new LoadException($uri);
     }
     $mimeType = $this->mimeTypeByResponse($response);
     if (null === $mimeType) {
         $mimeType = $this->extensionMap()->getByPath($this->pathFromUri($uri));
     }
     return new Content($response->getContent(), $mimeType);
 }
コード例 #2
0
ファイル: LoadException.php プロジェクト: eloquent/schemer
 /**
  * @param UriInterface   $uri
  * @param Exception|null $previous
  */
 public function __construct(UriInterface $uri, Exception $previous = null)
 {
     $this->uri = $uri;
     parent::__construct(sprintf('Unable to read from %s.', var_export($uri->toString(), true)), 0, $previous);
 }
コード例 #3
0
 /**
  * @param UriInterface $referenceUri
  *
  * @return Value\ValueInterface|null
  */
 protected function resolution(UriInterface $referenceUri)
 {
     $key = $referenceUri->toString();
     if (array_key_exists($key, $this->resolutions)) {
         return $this->resolutions[$key];
     }
     return null;
 }