1 | <?php |
||
15 | class RedirectRouter implements RouterInterface |
||
16 | { |
||
17 | /** @var RequestContext */ |
||
18 | private $context; |
||
19 | |||
20 | /** @var RouteCollection */ |
||
21 | private $routeCollection = null; |
||
22 | |||
23 | /** @var ObjectRepository */ |
||
24 | private $redirectRepository; |
||
25 | |||
26 | /** @var DomainConfigurationInterface */ |
||
27 | private $domainConfiguration; |
||
28 | |||
29 | /** |
||
30 | * @param ObjectRepository $redirectRepository |
||
31 | * @param DomainConfigurationInterface $domainConfiguration |
||
32 | */ |
||
33 | public function __construct(ObjectRepository $redirectRepository, DomainConfigurationInterface $domainConfiguration) |
||
39 | |||
40 | /** |
||
41 | * Generates a URL or path for a specific route based on the given parameters. |
||
42 | * |
||
43 | * Parameters that reference placeholders in the route pattern will substitute them in the |
||
44 | * path or host. Extra params are added as query string to the URL. |
||
45 | * |
||
46 | * When the passed reference type cannot be generated for the route because it requires a different |
||
47 | * host or scheme than the current one, the method will return a more comprehensive reference |
||
48 | * that includes the required params. For example, when you call this method with $referenceType = ABSOLUTE_PATH |
||
49 | * but the route requires the https scheme whereas the current scheme is http, it will instead return an |
||
50 | * ABSOLUTE_URL with the https scheme and the current host. This makes sure the generated URL matches |
||
51 | * the route in any case. |
||
52 | * |
||
53 | * If there is no route with the given name, the generator must throw the RouteNotFoundException. |
||
54 | * |
||
55 | * @param string $name The name of the route |
||
56 | * @param mixed $parameters An array of parameters |
||
57 | * @param bool|string $referenceType The type of reference to be generated (one of the constants) |
||
|
|||
58 | * |
||
59 | * @return string The generated URL |
||
60 | * |
||
61 | * @throws \Symfony\Component\Routing\Exception\RouteNotFoundException If the named route doesn't exist |
||
62 | * @throws \Symfony\Component\Routing\Exception\MissingMandatoryParametersException When some parameters are missing that are mandatory for the route |
||
63 | * @throws \Symfony\Component\Routing\Exception\InvalidParameterException When a parameter value for a placeholder is not correct because |
||
64 | * it does not match the requirement |
||
65 | * |
||
66 | * @api |
||
67 | */ |
||
68 | public function generate($name, $parameters = array(), $referenceType = self::ABSOLUTE_PATH) |
||
72 | |||
73 | /** |
||
74 | * Tries to match a URL path with a set of routes. |
||
75 | * |
||
76 | * If the matcher can not find information, it must throw one of the exceptions documented |
||
77 | * below. |
||
78 | * |
||
79 | * @param string $pathinfo The path info to be parsed (raw format, i.e. not urldecoded) |
||
80 | * |
||
81 | * @return array An array of parameters |
||
82 | * |
||
83 | * @throws \Symfony\Component\Routing\Exception\ResourceNotFoundException If the resource could not be found |
||
84 | * @throws \Symfony\Component\Routing\Exception\MethodNotAllowedException If the resource was found but the request method is not allowed |
||
85 | * |
||
86 | * @api |
||
87 | */ |
||
88 | public function match($pathinfo) |
||
95 | |||
96 | /** |
||
97 | * Gets the RouteCollection instance associated with this Router. |
||
98 | * |
||
99 | * @return \Symfony\Component\Routing\RouteCollection A RouteCollection instance |
||
100 | */ |
||
101 | public function getRouteCollection() |
||
110 | |||
111 | private function initRoutes() |
||
136 | |||
137 | /** |
||
138 | * @param Redirect $redirect |
||
139 | * |
||
140 | * @return bool |
||
141 | */ |
||
142 | private function isWildcardRedirect(Redirect $redirect) |
||
152 | |||
153 | private function isPathInfoWildcardMatch($matchSegment) |
||
159 | |||
160 | /** |
||
161 | * @param Redirect $redirect |
||
162 | * |
||
163 | * @return Route |
||
164 | */ |
||
165 | private function createRoute(Redirect $redirect) |
||
174 | |||
175 | /** |
||
176 | * @param Redirect $redirect |
||
177 | * |
||
178 | * @return Route |
||
179 | */ |
||
180 | private function createWildcardRoute(Redirect $redirect) |
||
199 | |||
200 | /** |
||
201 | * Gets the request context. |
||
202 | * |
||
203 | * @return \Symfony\Component\Routing\RequestContext The context |
||
204 | * |
||
205 | * @api |
||
206 | */ |
||
207 | public function getContext() |
||
211 | |||
212 | /** |
||
213 | * Sets the request context. |
||
214 | * |
||
215 | * @param RequestContext $context The context |
||
216 | * |
||
217 | * @api |
||
218 | */ |
||
219 | public function setContext(RequestContext $context) |
||
223 | } |
||
224 |
This check looks for
@param
annotations where the type inferred by our type inference engine differs from the declared type.It makes a suggestion as to what type it considers more descriptive.
Most often this is a case of a parameter that can be null in addition to its declared types.