Mercurial > hg > isophonics-drupal-site
diff vendor/symfony/routing/RouteCollection.php @ 14:1fec387a4317
Update Drupal core to 8.5.2 via Composer
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:46:53 +0100 |
parents | 4c8ae668cc8c |
children | 129ea1e6d783 |
line wrap: on
line diff
--- a/vendor/symfony/routing/RouteCollection.php Mon Apr 23 09:33:26 2018 +0100 +++ b/vendor/symfony/routing/RouteCollection.php Mon Apr 23 09:46:53 2018 +0100 @@ -104,7 +104,7 @@ /** * Removes a route or an array of routes by name from the collection. * - * @param string|array $name The route name or an array of route names + * @param string|string[] $name The route name or an array of route names */ public function remove($name) { @@ -116,10 +116,8 @@ /** * Adds a route collection at the end of the current set by appending all * routes of the added collection. - * - * @param RouteCollection $collection A RouteCollection instance */ - public function addCollection(RouteCollection $collection) + public function addCollection(self $collection) { // we need to remove all routes with the same names first because just replacing them // would not place the new route at the end of the merged array @@ -128,7 +126,9 @@ $this->routes[$name] = $route; } - $this->resources = array_merge($this->resources, $collection->getResources()); + foreach ($collection->getResources() as $resource) { + $this->addResource($resource); + } } /** @@ -234,7 +234,7 @@ /** * Sets the schemes (e.g. 'https') all child routes are restricted to. * - * @param string|array $schemes The scheme or an array of schemes + * @param string|string[] $schemes The scheme or an array of schemes */ public function setSchemes($schemes) { @@ -246,7 +246,7 @@ /** * Sets the HTTP methods (e.g. 'POST') all child routes are restricted to. * - * @param string|array $methods The method or an array of methods + * @param string|string[] $methods The method or an array of methods */ public function setMethods($methods) { @@ -262,16 +262,19 @@ */ public function getResources() { - return array_unique($this->resources); + return array_values($this->resources); } /** - * Adds a resource for this collection. - * - * @param ResourceInterface $resource A resource instance + * Adds a resource for this collection. If the resource already exists + * it is not added. */ public function addResource(ResourceInterface $resource) { - $this->resources[] = $resource; + $key = (string) $resource; + + if (!isset($this->resources[$key])) { + $this->resources[$key] = $resource; + } } }