1: <?php
2:
3: /**
4: * This file is part of the Nette Framework (https://nette.org)
5: * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
6: * @package Nette\Application\Responses
7: */
8:
9:
10:
11: /**
12: * String output response.
13: *
14: * @author David Grudl
15: *
16: * @property-read mixed $source
17: * @package Nette\Application\Responses
18: */
19: class TextResponse extends Object implements IPresenterResponse
20: {
21: /** @var mixed */
22: private $source;
23:
24:
25: /**
26: * @param mixed renderable variable
27: */
28: public function __construct($source)
29: {
30: $this->source = $source;
31: }
32:
33:
34: /**
35: * @return mixed
36: */
37: public function getSource()
38: {
39: return $this->source;
40: }
41:
42:
43: /**
44: * Sends response to output.
45: * @return void
46: */
47: public function send(IHttpRequest $httpRequest, IHttpResponse $httpResponse)
48: {
49: if ($this->source instanceof ITemplate) {
50: $this->source->render();
51:
52: } else {
53: echo $this->source;
54: }
55: }
56:
57: }
58: