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