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

getContentType() public method

Gets the format associated with the request.
public getContentType ( ) : string | null
return string | null The format (null if no content type is present)
    public function getContentType()
    {
        return $this->getFormat($this->headers->get('CONTENT_TYPE'));
    }

Usage Example

Example #1
0
 /**
  * @return array
  */
 public function getPostData()
 {
     if ('json' === $this->_internalRequest->getContentType()) {
         return (array) json_decode($this->_internalRequest->getContent(), true);
     } else {
         return $this->_internalRequest->request->all();
     }
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::getContentType