summaryrefslogtreecommitdiff
path: root/framework/Web/THttpResponseAdapter.php
blob: f0ced064b22b9b43ef84b92b76c3e8814397896a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
/**
 * THttpResponseAdatper class
 *
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 * @link http://www.pradosoft.com/
 * @copyright Copyright &copy; 2005-2014 PradoSoft
 * @license http://www.pradosoft.com/license/
 * @package Prado\Web
 */

namespace Prado\Web;

/**
 * THttpResponseAdapter class.
 *
 * THttpResponseAdapter allows the base http response class to change behavior
 * without change the class hierarchy.
 *
 * @author Wei Zhuo <weizhuo[at]gmail[dot]com>
 * @package Prado\Web
 * @since 3.0
 */
class THttpResponseAdapter extends TApplicationComponent
{
	/**
	 * @var THttpResponse the response object the adapter is attached.
	 */
	private $_response;

	/**
	 * Constructor. Attach a response to be adapted.
	 * @param THttpResponse the response object the adapter is to attach to.
	 */
	public function __construct($response)
	{
		$this->_response=$response;
	}

	/**
	 * @return THttpResponse the response object adapted.
	 */
	public function getResponse()
	{
		return $this->_response;
	}

	/**
	 * This method is invoked when the response flushes the content and headers.
	 * Default implementation calls the attached response flushContent method.
	 */
	public function flushContent()
	{
		$this->_response->flushContent();
	}

	/**
	 * This method is invoked when the response is to redirect to another page.
	 * @param string new url to redirect to.
	 */
	public function httpRedirect($url)
	{
		$this->_response->httpRedirect($url);
	}

	/**
	 * This method is invoked when a new HtmlWriter needs to be created.
	 * Default implementation calls the attached response createNewHtmlWriter method.
	 * @param string type of the HTML writer to be created.
	 * @param ITextWriter the writer responsible for holding the content.
	 */
	public function createNewHtmlWriter($type, $writer)
	{
		return $this->_response->createNewHtmlWriter($type,$writer);
	}
}