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

getRequestFormat() public method

Here is the process to determine the format: * format defined by the user (with setRequestFormat()) * _format request attribute * $default
public getRequestFormat ( string $default = 'html' ) : string
$default string The default format
return string The request format
    public function getRequestFormat($default = 'html')
    {
        if (null === $this->format) {
            $this->format = $this->attributes->get('_format', $default);
        }

        return $this->format;
    }

Usage Example

 function it_checks_if_its_a_html_request(Request $request)
 {
     $request->getRequestFormat()->willReturn('html');
     $this->isHtmlRequest()->shouldReturn(true);
     $request->getRequestFormat()->willReturn('json');
     $this->isHtmlRequest()->shouldReturn(false);
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Request::getRequestFormat