Symfony\Component\HttpFoundation\Response::isRedirection PHP Method

isRedirection() public method

Is the response a redirect?
public isRedirection ( ) : boolean
return boolean
    public function isRedirection()
    {
        return $this->statusCode >= 300 && $this->statusCode < 400;
    }

Usage Example

示例#1
0
 public function after(Request $request, Response $response, Application $app)
 {
     if ($response->isRedirection()) {
         return;
     }
     // if ('application/json' === $request->headers->get('Accept')) {
     //     return $this->app()->json($this->data);
     // }
     //https://blog.yorunohikage.fr/
     //Pretty printing all JSON output in Silex PHP
     //if($response instanceof JsonResponse) {
     //    $response->setEncodingOptions(JSON_PRETTY_PRINT);
     //}
     if ($request->isXmlHttpRequest()) {
         $response_data = array('status' => 'OK', 'data' => $this->data);
         if (!is_null($this->error)) {
             $response_data['status'] = 'ERROR';
             $response_data['error'] = $this->error;
         }
         return $this->app->json($response_data);
     }
     if ($response->getContent() == '') {
         $this->initTwig();
         $response->setContent($this->twig()->render($this->template, $this->data));
     }
 }
All Usage Examples Of Symfony\Component\HttpFoundation\Response::isRedirection