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