| 1441 |
ariadna |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/**
|
|
|
4 |
* Slim Framework (https://slimframework.com)
|
|
|
5 |
*
|
|
|
6 |
* @license https://github.com/slimphp/Slim/blob/4.x/LICENSE.md (MIT License)
|
|
|
7 |
*/
|
|
|
8 |
|
|
|
9 |
declare(strict_types=1);
|
|
|
10 |
|
|
|
11 |
namespace Slim\Handlers\Strategies;
|
|
|
12 |
|
|
|
13 |
use Psr\Http\Message\ResponseInterface;
|
|
|
14 |
use Psr\Http\Message\ServerRequestInterface;
|
|
|
15 |
use Slim\Interfaces\InvocationStrategyInterface;
|
|
|
16 |
|
|
|
17 |
use function array_values;
|
|
|
18 |
|
|
|
19 |
/**
|
|
|
20 |
* Route callback strategy with route parameters as individual arguments.
|
|
|
21 |
*/
|
|
|
22 |
class RequestResponseArgs implements InvocationStrategyInterface
|
|
|
23 |
{
|
|
|
24 |
/**
|
|
|
25 |
* Invoke a route callable with request, response and all route parameters
|
|
|
26 |
* as individual arguments.
|
|
|
27 |
*
|
|
|
28 |
* @param array<string, string> $routeArguments
|
|
|
29 |
*/
|
|
|
30 |
public function __invoke(
|
|
|
31 |
callable $callable,
|
|
|
32 |
ServerRequestInterface $request,
|
|
|
33 |
ResponseInterface $response,
|
|
|
34 |
array $routeArguments
|
|
|
35 |
): ResponseInterface {
|
|
|
36 |
return $callable($request, $response, ...array_values($routeArguments));
|
|
|
37 |
}
|
|
|
38 |
}
|