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: * Callback response.
15: */
16: class CallbackResponse extends Nette\Object implements Nette\Application\IResponse
17: {
18: /** @var callable */
19: private $callback;
20:
21:
22: /**
23: * @param callable function (Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
24: */
25: public function __construct($callback)
26: {
27: $this->callback = $callback;
28: }
29:
30:
31: /**
32: * Sends response to output.
33: * @return void
34: */
35: public function send(Nette\Http\IRequest $httpRequest, Nette\Http\IResponse $httpResponse)
36: {
37: call_user_func($this->callback, $httpRequest, $httpResponse);
38: }
39:
40: }
41: