/**
* @inheritdoc
*/
public function matchEncoder(AcceptHeaderInterface $acceptHeader)
{
foreach ($acceptHeader->getMediaTypes() as $headerMediaType) {
// if quality factor 'q' === 0 it means this type is not acceptable (RFC 2616 #3.9)
if ($headerMediaType->getQuality() > 0) {
/** @var MediaTypeInterface $registeredType */
foreach ($this->outputMediaTypes as list($registeredType, $closure)) {
if ($registeredType->matchesTo($headerMediaType) === true) {
$this->encoderHeaderMatchedType = $headerMediaType;
$this->encoderRegisteredMatchedType = $registeredType;
$this->foundEncoder = $closure;
return;
}
}
}
}
$this->encoderHeaderMatchedType = null;
$this->encoderRegisteredMatchedType = null;
$this->foundEncoder = null;
}