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