Symfony\Component\HttpFoundation\Request::getAcceptableContentTypes PHP Method

getAcceptableContentTypes() public method

Gets a list of content types acceptable by the client browser.
public getAcceptableContentTypes ( ) : array
return array List of content types in preferable order
    public function getAcceptableContentTypes()
    {
        if (null !== $this->acceptableContentTypes) {
            return $this->acceptableContentTypes;
        }

        return $this->acceptableContentTypes = array_keys(AcceptHeader::fromString($this->headers->get('Accept'))->all());
    }

Usage Example

Example #1
0
 /**
  * @return bool
  */
 private function shouldHandleRequest()
 {
     if ($this->handleNonJsonRequests) {
         return true;
     }
     return in_array('application/json', $this->request->getAcceptableContentTypes());
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::getAcceptableContentTypes