Symfony\Bundle\FrameworkBundle\Client::doRequest PHP Method

doRequest() protected method

Makes a request.
protected doRequest ( Request $request ) : Response
$request Symfony\Component\HttpFoundation\Request A Request instance
return Symfony\Component\HttpFoundation\Response A Response instance
    protected function doRequest($request)
    {
        // avoid shutting down the Kernel if no request has been performed yet
        // WebTestCase::createClient() boots the Kernel but do not handle a request
        if ($this->hasPerformedRequest) {
            $this->kernel->shutdown();
        } else {
            $this->hasPerformedRequest = true;
        }

        return $this->kernel->handle($request);
    }

Usage Example

Example #1
0
 /**
  * force all requests to be json like.
  *
  * Do JSON/RESTful requests using this client if the caller has not specified something else.
  *
  * @param object $request Request object
  *
  * @return \Symfony\Component\HttpFoundation\Response request
  */
 protected function doRequest($request)
 {
     if ($this->jsonRequest) {
         $request->headers->set('Content-Type', 'application/json; charset=UTF-8');
     }
     $request->headers->set('Accept', 'application/json');
     return parent::doRequest($request);
 }
All Usage Examples Of Symfony\Bundle\FrameworkBundle\Client::doRequest