Example #1
0
 public function setLocale($locale)
 {
     $this->locale = $locale;
     $response = new Response();
     $response->headers->setCookie(new \Symfony\Component\HttpFoundation\Cookie('app_locale', $locale, time() + 982222));
     $response->sendHeaders();
 }
Example #2
0
 /**
  * {@inheritdoc}
  *
  * This method only sends the headers once.
  */
 public function sendHeaders()
 {
     if ($this->headersSent) {
         return;
     }
     $this->headersSent = true;
     parent::sendHeaders();
 }
Example #3
0
 /**
  * Checks whether actual value is true
  * 
  * @param Response $response
  * @return boolean
  */
 public function matches($response)
 {
     if (!$response->isRedirect()) {
         $this->_actual = 'no url';
         return false;
     }
     $headers = $response->sendHeaders();
     $this->_actual = str_replace('Location: ', '', $headers['location']);
     return $this->_actual === $this->_expected;
 }
Example #4
0
 public function writeResponse($response_data)
 {
     $response = new Response($this);
     $response->setStatus($response_data[0]);
     for ($i = 0, $cnt = count($response_data[1]); $i < $cnt; $i++) {
         $response->addHeader($response_data[1][$i], $response_data[1][++$i]);
     }
     $response->sendHeaders();
     $this->write($response_data[2]);
     // body
 }
 public function writeResponse($response_data)
 {
     $response = new Response($this);
     $response->setStatus($response_data[0]);
     for ($i = 0, $cnt = count($response_data[1]); $i < $cnt; $i++) {
         $response->addHeader($response_data[1][$i], $response_data[1][++$i]);
     }
     $response->sendHeaders();
     if (!is_resource($response_data[2])) {
         $this->write($response_data[2]);
     } else {
         while (!feof($response_data[2])) {
             $this->write(fread($response_data[2], 1024));
         }
     }
 }
 public function __construct($path)
 {
     parent::setHeader('Location', $path);
     return parent::sendHeaders();
 }
Example #7
0
 /**
  * @param string $uri
  * @param integer $code HTTP status codes
  * @return void
  */
 public function redirect($uri, $code = Response::FOUND)
 {
     $response = new Response();
     $response->setCode($code);
     $response->addHeader('Location: ' . $uri);
     $response->sendHeaders();
     exit;
 }
Example #8
0
 /**
  * renders the view and sets the body of the response objec
  * @return Response object
  */
 public function render()
 {
     $this->response->body($this->view->render($this->template));
     $this->response->sendHeaders();
     return $this->response;
 }