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