1 | <?php |
||
11 | final class Redirect implements MiddlewareInterface |
||
12 | { |
||
13 | public const PERMANENT = 301; |
||
14 | public const TEMPORARY = 302; |
||
15 | |||
16 | private $uri; |
||
17 | private $route; |
||
18 | private $parameters = []; |
||
19 | private $statusCode = self::PERMANENT; |
||
20 | private $responseFactory; |
||
21 | private $urlGenerator; |
||
22 | |||
23 | private function __construct(ResponseFactoryInterface $responseFactory, UrlGeneratorInterface $urlGenerator) |
||
28 | |||
29 | public function toUrl(string $url): self |
||
34 | |||
35 | public function toRoute(string $name, array $parameters = []): self |
||
41 | |||
42 | public function status(int $code): self |
||
47 | |||
48 | public function permanent(): self |
||
53 | |||
54 | public function temporary(): self |
||
59 | |||
60 | public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface |
||
74 | } |
||
75 |