pradosoft /
prado
| 1 | <?php |
||
| 2 | |||
| 3 | /** |
||
| 4 | * THttpResponseAdatper class |
||
| 5 | * |
||
| 6 | * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
||
| 7 | * @link https://github.com/pradosoft/prado |
||
| 8 | * @license https://github.com/pradosoft/prado/blob/master/LICENSE |
||
| 9 | */ |
||
| 10 | |||
| 11 | namespace Prado\Web; |
||
| 12 | |||
| 13 | use Prado\Exceptions\TInvalidOperationException; |
||
| 14 | |||
| 15 | /** |
||
| 16 | * THttpResponseAdapter class. |
||
| 17 | * |
||
| 18 | * THttpResponseAdapter allows the base http response class to change behavior |
||
| 19 | * without change the class hierarchy. |
||
| 20 | * |
||
| 21 | * @author Wei Zhuo <weizhuo[at]gmail[dot]com> |
||
| 22 | * @since 3.0 |
||
| 23 | */ |
||
| 24 | class THttpResponseAdapter extends \Prado\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 $response the response object the adapter is to attach to. |
||
| 34 | */ |
||
| 35 | public function __construct($response) |
||
| 36 | { |
||
| 37 | $this->_response = $response; |
||
| 38 | parent::__construct(); |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @return THttpResponse the response object adapted. |
||
| 43 | */ |
||
| 44 | public function getResponse() |
||
| 45 | { |
||
| 46 | return $this->_response; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * This method is invoked when the response flushes the content and headers. |
||
| 51 | * Default implementation calls the attached response flushContent method. |
||
| 52 | * @param bool $continueBuffering |
||
| 53 | */ |
||
| 54 | public function flushContent($continueBuffering = true) |
||
| 55 | { |
||
| 56 | $this->_response->flushContent($continueBuffering); |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * This method is invoked when the response is to redirect to another page. |
||
| 61 | * @param string $url new url to redirect to. |
||
| 62 | */ |
||
| 63 | public function httpRedirect($url) |
||
| 64 | { |
||
| 65 | $this->_response->httpRedirect($url); |
||
| 66 | } |
||
| 67 | |||
| 68 | /** |
||
| 69 | * This method is invoked when a new HtmlWriter needs to be created. |
||
| 70 | * Default implementation calls the attached response createNewHtmlWriter method. |
||
| 71 | * @param string $type type of the HTML writer to be created. |
||
| 72 | * @param \Prado\IO\ITextWriter $writer the writer responsible for holding the content. |
||
| 73 | */ |
||
| 74 | public function createNewHtmlWriter($type, $writer) |
||
| 75 | { |
||
| 76 | return $this->_response->createNewHtmlWriter($type, $writer); |
||
| 77 | } |
||
| 78 | |||
| 79 | /** |
||
| 80 | * @param mixed $data |
||
| 81 | * @throws TInvalidOperationException |
||
| 82 | */ |
||
| 83 | public function setResponseData($data) |
||
|
0 ignored issues
–
show
|
|||
| 84 | { |
||
| 85 | throw new TInvalidOperationException('httpresponse_responsedata_method_unavailable', __METHOD__); |
||
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @throws TInvalidOperationException |
||
| 90 | */ |
||
| 91 | public function getResponseData() |
||
| 92 | { |
||
| 93 | throw new TInvalidOperationException('httpresponse_responsedata_method_unavailable', __METHOD__); |
||
| 94 | } |
||
| 95 | } |
||
| 96 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.