Exemplo n.º 1
0
 /**
  * Render response and send it to the client
  */
 public function send()
 {
     if (Util\Debug::isActivated()) {
         $this->add(Util\Debug::getInstance());
     }
     $this->response->setContent($this->render());
     return $this->response;
 }
Exemplo n.º 2
0
 /**
  * Sets caching mode for the browser
  *
  * @todo implement remaining caching modes
  * @param $mode
  * @param integer $value timestamp in seconds or offset in seconds
  */
 public function setCaching($mode, $value)
 {
     switch ($mode) {
         case 'modified':
             // Last-modified
             $this->response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $value) . ' GMT');
         case 'expires':
             // Expire
             $this->response->setHeader('Expires', gmdate('D, d M Y H:i:s', $value) . ' GMT');
             break;
         case 'age':
             // Cache-control: max-age=
             $this->response->setHeader('Cache-control', 'max-age=' . $value);
             break;
         case 'off':
         case FALSE:
             $this->response->setHeader('Cache-control', 'no-cache');
             $this->response->setHeader('Pragma', 'no-cache');
         default:
             throw new Exception('Unknown caching mode: \'' . $mode . '\'');
     }
 }
Exemplo n.º 3
0
 /**
  * Sets caching mode for the browser
  *
  * @todo implement remaining caching modes
  * @param $mode
  * @param integer $value timestamp in seconds or offset in seconds
  */
 public function setCaching($mode, $value)
 {
     // unresolved artifact from Symfony migration
     throw new \LogicException('Cannot set caching in view without access to response');
     switch ($mode) {
         case 'modified':
             // Last-modified
             $this->response->setHeader('Last-Modified', gmdate('D, d M Y H:i:s', $value) . ' GMT');
         case 'expires':
             // Expire
             $this->response->setHeader('Expires', gmdate('D, d M Y H:i:s', $value) . ' GMT');
             break;
         case 'age':
             // Cache-control: max-age=
             $this->response->setHeader('Cache-control', 'max-age=' . $value);
             break;
         case 'off':
         case FALSE:
             $this->response->setHeader('Cache-control', 'no-cache');
             $this->response->setHeader('Pragma', 'no-cache');
         default:
             throw new \Exception('Unknown caching mode: \'' . $mode . '\'');
     }
 }