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: /**
19: * String output response.
20: *
21: * @author David Grudl
22: *
23: * @property-read mixed $source
24: */
25: class TextResponse extends Nette\Object implements Nette\Application\IResponse
26: {
27: /** @var mixed */
28: private $source;
29:
30:
31:
32: /**
33: * @param mixed renderable variable
34: */
35: public function __construct($source)
36: {
37: $this->source = $source;
38: }
39:
40:
41:
42: /**
43: * @return mixed
44: */
45: final public function getSource()
46: {
47: return $this->source;
48: }
49:
50:
51:
52: /**
53: * Sends response to output.
54: * @return void
55: */
56: public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
57: {
58: if ($this->source instanceof Nette\Templating\ITemplate) {
59: $this->source->render();
60:
61: } else {
62: echo $this->source;
63: }
64: }
65:
66: }
67: