| 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\Interfaces;
|
|
|
12 |
|
|
|
13 |
use InvalidArgumentException;
|
|
|
14 |
use RuntimeException;
|
|
|
15 |
|
|
|
16 |
interface RouteCollectorInterface
|
|
|
17 |
{
|
|
|
18 |
/**
|
|
|
19 |
* Get the route parser
|
|
|
20 |
*/
|
|
|
21 |
public function getRouteParser(): RouteParserInterface;
|
|
|
22 |
|
|
|
23 |
/**
|
|
|
24 |
* Get default route invocation strategy
|
|
|
25 |
*/
|
|
|
26 |
public function getDefaultInvocationStrategy(): InvocationStrategyInterface;
|
|
|
27 |
|
|
|
28 |
/**
|
|
|
29 |
* Set default route invocation strategy
|
|
|
30 |
*/
|
|
|
31 |
public function setDefaultInvocationStrategy(InvocationStrategyInterface $strategy): RouteCollectorInterface;
|
|
|
32 |
|
|
|
33 |
/**
|
|
|
34 |
* Get path to FastRoute cache file
|
|
|
35 |
*/
|
|
|
36 |
public function getCacheFile(): ?string;
|
|
|
37 |
|
|
|
38 |
/**
|
|
|
39 |
* Set path to FastRoute cache file
|
|
|
40 |
*
|
|
|
41 |
* @throws InvalidArgumentException
|
|
|
42 |
* @throws RuntimeException
|
|
|
43 |
*/
|
|
|
44 |
public function setCacheFile(string $cacheFile): RouteCollectorInterface;
|
|
|
45 |
|
|
|
46 |
/**
|
|
|
47 |
* Get the base path used in pathFor()
|
|
|
48 |
*/
|
|
|
49 |
public function getBasePath(): string;
|
|
|
50 |
|
|
|
51 |
/**
|
|
|
52 |
* Set the base path used in pathFor()
|
|
|
53 |
*/
|
|
|
54 |
public function setBasePath(string $basePath): RouteCollectorInterface;
|
|
|
55 |
|
|
|
56 |
/**
|
|
|
57 |
* Get route objects
|
|
|
58 |
*
|
|
|
59 |
* @return RouteInterface[]
|
|
|
60 |
*/
|
|
|
61 |
public function getRoutes(): array;
|
|
|
62 |
|
|
|
63 |
/**
|
|
|
64 |
* Get named route object
|
|
|
65 |
*
|
|
|
66 |
* @param string $name Route name
|
|
|
67 |
*
|
|
|
68 |
* @throws RuntimeException If named route does not exist
|
|
|
69 |
*/
|
|
|
70 |
public function getNamedRoute(string $name): RouteInterface;
|
|
|
71 |
|
|
|
72 |
/**
|
|
|
73 |
* Remove named route
|
|
|
74 |
*
|
|
|
75 |
* @param string $name Route name
|
|
|
76 |
*
|
|
|
77 |
* @throws RuntimeException If named route does not exist
|
|
|
78 |
*/
|
|
|
79 |
public function removeNamedRoute(string $name): RouteCollectorInterface;
|
|
|
80 |
|
|
|
81 |
/**
|
|
|
82 |
* Lookup a route via the route's unique identifier
|
|
|
83 |
*
|
|
|
84 |
* @throws RuntimeException If route of identifier does not exist
|
|
|
85 |
*/
|
|
|
86 |
public function lookupRoute(string $identifier): RouteInterface;
|
|
|
87 |
|
|
|
88 |
/**
|
|
|
89 |
* Add route group
|
|
|
90 |
* @param string|callable $callable
|
|
|
91 |
*/
|
|
|
92 |
public function group(string $pattern, $callable): RouteGroupInterface;
|
|
|
93 |
|
|
|
94 |
/**
|
|
|
95 |
* Add route
|
|
|
96 |
*
|
|
|
97 |
* @param string[] $methods Array of HTTP methods
|
|
|
98 |
* @param string $pattern The route pattern
|
|
|
99 |
* @param callable|string $handler The route callable
|
|
|
100 |
*/
|
|
|
101 |
public function map(array $methods, string $pattern, $handler): RouteInterface;
|
|
|
102 |
}
|