| 1 |
lars |
1 |
<?php
|
|
|
2 |
/**
|
|
|
3 |
* THttpResponseAdatper class
|
|
|
4 |
*
|
|
|
5 |
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
|
|
|
6 |
* @link http://www.pradosoft.com/
|
|
|
7 |
* @copyright Copyright © 2005-2008 PradoSoft
|
|
|
8 |
* @license http://www.pradosoft.com/license/
|
|
|
9 |
* @version $Id$
|
|
|
10 |
* @package System.Web
|
|
|
11 |
*/
|
|
|
12 |
|
|
|
13 |
/**
|
|
|
14 |
* THttpResponseAdapter class.
|
|
|
15 |
*
|
|
|
16 |
* THttpResponseAdapter allows the base http response class to change behavior
|
|
|
17 |
* without change the class hierarchy.
|
|
|
18 |
*
|
|
|
19 |
* @author Wei Zhuo <weizhuo[at]gmail[dot]com>
|
|
|
20 |
* @version $Id$
|
|
|
21 |
* @package System.Web
|
|
|
22 |
* @since 3.0
|
|
|
23 |
*/
|
|
|
24 |
class THttpResponseAdapter extends TApplicationComponent
|
|
|
25 |
{
|
|
|
26 |
/**
|
|
|
27 |
* @var THttpResponse the response object the adapter is attached.
|
|
|
28 |
*/
|
|
|
29 |
private $_response;
|
|
|
30 |
|
|
|
31 |
/**
|
|
|
32 |
* Constructor. Attach a response to be adapted.
|
|
|
33 |
* @param THttpResponse the response object the adapter is to attach to.
|
|
|
34 |
*/
|
|
|
35 |
public function __construct($response)
|
|
|
36 |
{
|
|
|
37 |
$this->_response=$response;
|
|
|
38 |
}
|
|
|
39 |
|
|
|
40 |
/**
|
|
|
41 |
* @return THttpResponse the response object adapted.
|
|
|
42 |
*/
|
|
|
43 |
public function getResponse()
|
|
|
44 |
{
|
|
|
45 |
return $this->_response;
|
|
|
46 |
}
|
|
|
47 |
|
|
|
48 |
/**
|
|
|
49 |
* This method is invoked when the response flushes the content and headers.
|
|
|
50 |
* Default implementation calls the attached response flushContent method.
|
|
|
51 |
*/
|
|
|
52 |
public function flushContent()
|
|
|
53 |
{
|
|
|
54 |
$this->_response->flushContent();
|
|
|
55 |
}
|
|
|
56 |
|
|
|
57 |
/**
|
|
|
58 |
* This method is invoked when the response is to redirect to another page.
|
|
|
59 |
* @param string new url to redirect to.
|
|
|
60 |
*/
|
|
|
61 |
public function httpRedirect($url)
|
|
|
62 |
{
|
|
|
63 |
$this->_response->httpRedirect($url);
|
|
|
64 |
}
|
|
|
65 |
|
|
|
66 |
/**
|
|
|
67 |
* This method is invoked when a new HtmlWriter needs to be created.
|
|
|
68 |
* Default implementation calls the attached response createNewHtmlWriter method.
|
|
|
69 |
* @param string type of the HTML writer to be created.
|
|
|
70 |
* @param ITextWriter the writer responsible for holding the content.
|
|
|
71 |
*/
|
|
|
72 |
public function createNewHtmlWriter($type, $writer)
|
|
|
73 |
{
|
|
|
74 |
return $this->_response->createNewHtmlWriter($type,$writer);
|
|
|
75 |
}
|
|
|
76 |
}
|
|
|
77 |
|
|
|
78 |
?>
|