This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.
Sequenzia/Rails/ActionController/Response.php

81 lines
1.6 KiB
PHP
Raw Normal View History

2013-10-02 08:12:58 +02:00
<?php
namespace Rails\ActionController;
use Rails\ActionDispatch\ActionDispatch;
class Response extends ActionDispatch
{
private
/**
* ActionController_Cookies instance
*/
$cookies,
$body;
/**
* If set to false, cookies and headers won't be send.
*/
protected $send_headers = true;
public function cookies()
{
if (!$this->cookies)
$this->cookies = new Cookies();
return $this->cookies;
}
public function headers()
{
return \Rails::application()->dispatcher()->headers();
}
public function body($body = null)
{
if (null !== $body) {
$this->body = $body;
return $this;
} else {
return $this->body;
}
}
public function sendHeaders($value = null)
{
if ($value === null)
return $this->send_headers;
else {
$this->send_headers = $value;
return $this;
}
}
public function send_headers($value = null)
{
if ($value === null)
return $this->send_headers;
else {
$this->send_headers = $value;
return $this;
}
}
protected function _init()
{
}
protected function _respond()
{
$this->_send_headers();
echo $this->body;
$this->body = null;
}
private function _send_headers()
{
if ($this->send_headers) {
$this->headers()->send();
$this->cookies()->set();
}
}
}