getMediaTypes() public method

Get sorted/ranged media types (by quality factor, type, subtype and extensions).
public getMediaTypes ( ) : Neomerx\JsonApi\Contracts\Http\Headers\AcceptMediaTypeInterface[]
return Neomerx\JsonApi\Contracts\Http\Headers\AcceptMediaTypeInterface[]
Beispiel #1
0
 /**
  * @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;
 }