1 | <?php |
||
22 | class UrlAliasGenerator extends Generator |
||
23 | { |
||
24 | const INTERNAL_LOCATION_ROUTE = '_ezpublishLocation'; |
||
25 | const INTERNAL_CONTENT_VIEW_ROUTE = '_ez_content_view'; |
||
26 | |||
27 | /** @var \eZ\Publish\Core\Repository\Repository */ |
||
28 | private $repository; |
||
29 | |||
30 | /** |
||
31 | * The default router (that works with declared routes). |
||
32 | * |
||
33 | * @var \Symfony\Component\Routing\RouterInterface |
||
34 | */ |
||
35 | private $defaultRouter; |
||
36 | |||
37 | /** @var int */ |
||
38 | private $rootLocationId; |
||
39 | |||
40 | /** @var array */ |
||
41 | private $excludedUriPrefixes = []; |
||
42 | |||
43 | /** @var array */ |
||
44 | private $pathPrefixMap = []; |
||
45 | |||
46 | /** @var \eZ\Publish\Core\MVC\ConfigResolverInterface */ |
||
47 | private $configResolver; |
||
48 | |||
49 | /** |
||
50 | * Array of characters that are potentially unsafe for output for (x)html, json, etc, |
||
51 | * and respective url-encoded value. |
||
52 | * |
||
53 | * @var array |
||
54 | */ |
||
55 | private $unsafeCharMap; |
||
56 | |||
57 | public function __construct(Repository $repository, RouterInterface $defaultRouter, ConfigResolverInterface $configResolver, array $unsafeCharMap = []) |
||
64 | |||
65 | /** |
||
66 | * Generates the URL from $urlResource and $parameters. |
||
67 | * Entries in $parameters will be added in the query string. |
||
68 | * |
||
69 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
70 | * @param array $parameters |
||
71 | * |
||
72 | * @return string |
||
73 | */ |
||
74 | public function doGenerate($location, array $parameters) |
||
86 | |||
87 | /** |
||
88 | * Injects current root locationId that will be used for link generation. |
||
89 | * |
||
90 | * @param int $rootLocationId |
||
91 | */ |
||
92 | public function setRootLocationId($rootLocationId) |
||
96 | |||
97 | /** |
||
98 | * @param array $excludedUriPrefixes |
||
99 | */ |
||
100 | public function setExcludedUriPrefixes(array $excludedUriPrefixes) |
||
104 | |||
105 | /** |
||
106 | * Returns path corresponding to $rootLocationId. |
||
107 | * |
||
108 | * @param int $rootLocationId |
||
109 | * @param array $languages |
||
110 | * @param string $siteaccess |
||
111 | * |
||
112 | * @return string |
||
113 | */ |
||
114 | public function getPathPrefixByRootLocationId($rootLocationId, $languages = null, $siteaccess = null) |
||
138 | |||
139 | /** |
||
140 | * Checks if passed URI has an excluded prefix, when a root location is defined. |
||
141 | * |
||
142 | * @param string $uri |
||
143 | * |
||
144 | * @return bool |
||
145 | */ |
||
146 | public function isUriPrefixExcluded($uri) |
||
157 | |||
158 | /** |
||
159 | * Loads a location by its locationId, regardless to user limitations since the router is invoked BEFORE security (no user authenticated yet). |
||
160 | * Not to be used for link generation. |
||
161 | * |
||
162 | * @param int $locationId |
||
163 | * |
||
164 | * @return \eZ\Publish\Core\Repository\Values\Content\Location |
||
165 | */ |
||
166 | public function loadLocation($locationId) |
||
175 | |||
176 | /** |
||
177 | * @param \eZ\Publish\API\Repository\Values\Content\Location $location |
||
178 | * @param string|null $siteaccess |
||
179 | * |
||
180 | * @return string |
||
181 | */ |
||
182 | private function createPathString(Location $location, ?string $siteaccess = null): string |
||
221 | |||
222 | /** |
||
223 | * Creates query string from parameters. If `_fragment` parameter is provided then |
||
224 | * fragment identifier is added at the end of the URL. |
||
225 | * |
||
226 | * @param array $parameters |
||
227 | * |
||
228 | * @return string |
||
229 | */ |
||
230 | private function createQueryString(array $parameters): string |
||
249 | |||
250 | /** |
||
251 | * Replace potentially unsafe characters with url-encoded counterpart. |
||
252 | * |
||
253 | * @param string $url |
||
254 | * |
||
255 | * @return string |
||
256 | */ |
||
257 | private function filterCharactersOfURL(string $url): string |
||
261 | } |
||
262 |
Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a given class or a super-class is assigned to a property that is type hinted more strictly.
Either this assignment is in error or an instanceof check should be added for that assignment.