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