1 | <?php |
||
15 | class I18nRouter implements RouterInterface, WarmableInterface |
||
16 | { |
||
17 | /** |
||
18 | * @var RouterInterface |
||
19 | */ |
||
20 | private $router; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $defaultLocale; |
||
26 | |||
27 | 4 | public function __construct(RouterInterface $router, string $defaultLocale) |
|
32 | |||
33 | 2 | public function setContext(RequestContext $context) |
|
37 | |||
38 | 2 | public function getContext() |
|
42 | |||
43 | 2 | public function getRouteCollection() |
|
47 | |||
48 | /** |
||
49 | * Generates a URL or path for a specific route based on the given parameters. |
||
50 | * |
||
51 | * Parameters that reference placeholders in the route pattern will substitute them in the |
||
52 | * path or host. Extra params are added as query string to the URL. |
||
53 | * |
||
54 | * When the passed reference type cannot be generated for the route because it requires a different |
||
55 | * host or scheme than the current one, the method will return a more comprehensive reference |
||
56 | * that includes the required params. For example, when you call this method with $referenceType = ABSOLUTE_PATH |
||
57 | * but the route requires the https scheme whereas the current scheme is http, it will instead return an |
||
58 | * ABSOLUTE_URL with the https scheme and the current host. This makes sure the generated URL matches |
||
59 | * the route in any case. |
||
60 | * |
||
61 | * If there is no route with the given name, the generator must throw the RouteNotFoundException. |
||
62 | * |
||
63 | * The special parameter _fragment will be used as the document fragment suffixed to the final URL. |
||
64 | * |
||
65 | * @param string $name The name of the route |
||
66 | * @param mixed $parameters An array of parameters |
||
67 | * @param int $referenceType The type of reference to be generated (one of the constants) |
||
68 | * |
||
69 | * @return string The generated URL |
||
70 | * |
||
71 | * @throws RouteNotFoundException If the named route doesn't exist |
||
72 | * @throws MissingMandatoryParametersException When some parameters are missing that are mandatory for the route |
||
73 | * @throws InvalidParameterException When a parameter value for a placeholder is not correct because |
||
74 | * it does not match the requirement |
||
75 | */ |
||
76 | 2 | public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH) |
|
91 | |||
92 | /** |
||
93 | * Tries to match a URL path with a set of routes. |
||
94 | * |
||
95 | * If the matcher can not find information, it must throw one of the exceptions documented |
||
96 | * below. |
||
97 | * |
||
98 | * @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded) |
||
99 | * |
||
100 | * @return array An array of parameters |
||
101 | * |
||
102 | * @throws NoConfigurationException If no routing configuration could be found |
||
103 | * @throws ResourceNotFoundException If the resource could not be found |
||
104 | * @throws MethodNotAllowedException If the resource was found but the request method is not allowed |
||
105 | */ |
||
106 | 2 | public function match($pathinfo) |
|
110 | |||
111 | /** |
||
112 | * Warms up the cache. |
||
113 | * |
||
114 | * @param string $cacheDir The cache directory |
||
115 | */ |
||
116 | 2 | public function warmUp($cacheDir) |
|
122 | } |