public function accept(MediaType $contentType) { if ($this->contentType === null) { return true; } elseif (is_string($this->contentType)) { return $this->contentType == $contentType->getName(); } elseif (is_callable($this->contentType)) { return call_user_func_array($this->contentType, array($contentType)); } return false; }
public function accept(MediaType $contentType) { return in_array($contentType->getName(), MediaType\Xml::getMediaTypes()) || substr($contentType->getSubType(), -4) == '+xml' || substr($contentType->getSubType(), -4) == '/xml'; }
public function isContentTypeSupported(MediaType $contentType) { return $contentType->getName() == self::$mime; }
public function accept(MediaType $contentType) { return $contentType->getName() == 'application/jsonx+xml'; }
public function isContentTypeSupported(MediaType $contentType) { return $contentType->getName() == 'application/x-www-form-urlencoded'; }
/** * Returns the fitting writer according to the content negotiation. If no * fitting writer could be found null gets returned * * @param \PSX\Http\MediaType $contentType * @param array $supportedWriter * @return \PSX\Data\WriterInterface */ protected function getWriterFromContentNegotiation(MediaType $contentType, array $supportedWriter = null) { if (empty($this->contentNegotiation)) { return null; } foreach ($this->contentNegotiation as $acceptedContentType => $writerClass) { if ($supportedWriter !== null && !in_array($writerClass, $supportedWriter)) { continue; } $acceptedContentType = new MediaType($acceptedContentType); if ($acceptedContentType->match($contentType)) { $writer = $this->getWriterByInstance($writerClass); if ($writer !== null) { return $writer; } } } return null; }
/** * Checks whether the given media type would match * * @param \PSX\Http\MediaType $mediaType * @return boolean */ public function match(MediaType $mediaType) { return $this->type == '*' && $this->subType == '*' || $this->type == $mediaType->getType() && $this->subType == $mediaType->getSubType() || $this->type == $mediaType->getType() && $this->subType == '*'; }
public static function isMediaType(MediaType $mediaType) { return in_array($mediaType->getName(), self::$mediaTypes) || substr($mediaType->getSubType(), -4) == '+xml' || substr($mediaType->getSubType(), -4) == '/xml'; }