Пример #1
0
 /**
  * Guarantee the correct media type was encountered
  *
  * @param UriRetrieverInterface $uriRetriever
  * @param string $uri
  * @return bool|void
  */
 public function confirmMediaType($uriRetriever, $uri)
 {
     $contentType = $uriRetriever->getContentType();
     if (is_null($contentType)) {
         // Well, we didn't get an invalid one
         return;
     }
     if (Validator::SCHEMA_MEDIA_TYPE === $contentType) {
         return;
     }
     if (substr($uri, 0, 23) == 'http://json-schema.org/') {
         //HACK; they deliver broken content types
         return true;
     }
     throw new InvalidSchemaMediaTypeException(sprintf('Media type %s expected', Validator::SCHEMA_MEDIA_TYPE));
 }
Пример #2
0
 /**
  * {@inheritdoc}
  */
 public function getContentType()
 {
     return $this->lastUsedRetriever ? $this->lastUsedRetriever->getContentType() : null;
 }