diff --git a/core/lib/Drupal/Core/RouteProcessor/RouteProcessorCurrent.php b/core/lib/Drupal/Core/RouteProcessor/RouteProcessorCurrent.php index 17a56b5..3fc61b9 100644 --- a/core/lib/Drupal/Core/RouteProcessor/RouteProcessorCurrent.php +++ b/core/lib/Drupal/Core/RouteProcessor/RouteProcessorCurrent.php @@ -39,8 +39,15 @@ public function __construct(RouteMatchInterface $route_match) { public function processOutbound($route_name, Route $route, array &$parameters, CacheableMetadata $cacheable_metadata = NULL) { if ($route_name === '') { if ($current_route = $this->routeMatch->getRouteObject()) { + $requirements = $current_route->getRequirements(); + unset($requirements['_format']); + unset($requirements['_method']); + unset($requirements['_schema']); + $route->setRequirements($requirements); + $route->setPath($current_route->getPath()); - $route->setRequirements($current_route->getRequirements()); + $route->setSchemes($current_route->getSchemes()); + $route->setMethods($current_route->getMethods()); $route->setOptions($current_route->getOptions()); $route->setDefaults($current_route->getDefaults()); $parameters = array_merge($parameters, $this->routeMatch->getRawParameters()->all()); diff --git a/core/lib/Drupal/Core/Routing/UrlGenerator.php b/core/lib/Drupal/Core/Routing/UrlGenerator.php index c7686c6..081a542 100644 --- a/core/lib/Drupal/Core/Routing/UrlGenerator.php +++ b/core/lib/Drupal/Core/Routing/UrlGenerator.php @@ -345,8 +345,8 @@ public function generateFromRoute($name, $parameters = array(), $options = array else { $scheme = $this->context->getScheme(); } - $scheme_req = $route->getRequirement('_scheme'); - if (isset($scheme_req) && ($req = strtolower($scheme_req)) && $scheme !== $req) { + $scheme_req = $route->getSchemes(); + if ($scheme_req && ($req = $scheme_req[0]) && $scheme !== $req) { $scheme = $req; } $port = ''; diff --git a/core/modules/rest/src/Plugin/ResourceBase.php b/core/modules/rest/src/Plugin/ResourceBase.php index 46f77f6..14bca5e 100644 --- a/core/modules/rest/src/Plugin/ResourceBase.php +++ b/core/modules/rest/src/Plugin/ResourceBase.php @@ -203,10 +203,14 @@ protected function getBaseRoute($canonical_path, $method) { // Pass the resource plugin ID along as default property. '_plugin' => $this->pluginId, ), array( - // The HTTP method is a requirement for this route. - '_method' => $method, '_permission' => "restful $lower_method $this->pluginId", - )); + ), + array(), + array(), + array(), + // The HTTP method is a requirement for this route. + array($method) + ); return $route; } diff --git a/core/modules/rest/src/Plugin/views/display/RestExport.php b/core/modules/rest/src/Plugin/views/display/RestExport.php index 2efdbc7..32c0110 100644 --- a/core/modules/rest/src/Plugin/views/display/RestExport.php +++ b/core/modules/rest/src/Plugin/views/display/RestExport.php @@ -263,7 +263,7 @@ public function collectRoutes(RouteCollection $collection) { if ($route = $collection->get("view.$view_id.$display_id")) { $style_plugin = $this->getPlugin('style'); // REST exports should only respond to get methods. - $requirements = array('_method' => 'GET'); + $route->setMethods(['GET']); // Format as a string using pipes as a delimiter. $requirements['_format'] = implode('|', $style_plugin->getFormats()); diff --git a/core/modules/simpletest/src/WebTestBase.php b/core/modules/simpletest/src/WebTestBase.php index 99cb227..0f80061 100644 --- a/core/modules/simpletest/src/WebTestBase.php +++ b/core/modules/simpletest/src/WebTestBase.php @@ -724,7 +724,8 @@ protected function setUp() { if ($this->strictConfigSchema) { // Add a listener to validate configuration schema on save. $yaml = new \Symfony\Component\Yaml\Yaml(); - $services = $yaml->parse($directory . '/services.yml'); + $content = file_get_contents($directory . '/services.yml'); + $services = $yaml->parse($content); $services['services']['simpletest.config_schema_checker'] = [ 'class' => 'Drupal\Core\Config\Testing\ConfigSchemaChecker', 'arguments' => ['@config.typed'], diff --git a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php index ffbfb03..59082d6 100644 --- a/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php +++ b/core/tests/Drupal/Tests/Core/Routing/RoutingFixtures.php @@ -90,15 +90,15 @@ public function sampleRouteCollection() { $collection = new RouteCollection(); $route = new Route('path/one'); - $route->setRequirement('_method', 'GET'); + $route->setMethods(['GET']); $collection->add('route_a', $route); $route = new Route('path/one'); - $route->setRequirement('_method', 'PUT'); + $route->setMethods(['PUT']); $collection->add('route_b', $route); $route = new Route('path/two'); - $route->setRequirement('_method', 'GET'); + $route->setMethods(['GET']); $route->setRequirement('_format', 'json'); $collection->add('route_c', $route); @@ -106,7 +106,7 @@ public function sampleRouteCollection() { $collection->add('route_d', $route); $route = new Route('path/two'); - $route->setRequirement('_method', 'GET|HEAD'); + $route->setMethods(['GET', 'HEAD']); $route->setRequirement('_format', 'html'); $collection->add('route_e', $route); @@ -122,22 +122,22 @@ public function complexRouteCollection() { $collection = new RouteCollection(); $route = new Route('/path/{thing}/one'); - $route->setRequirement('_method', 'GET'); + $route->setMethods(['GET']); $collection->add('route_a', $route); $route = new Route('/path/{thing}/one'); - $route->setRequirement('_method', 'PUT'); + $route->setMethods(['PUT']); $collection->add('route_b', $route); $route = new Route('/somewhere/{item}/over/the/rainbow'); - $route->setRequirement('_method', 'GET'); + $route->setMethods(['GET']); $collection->add('route_c', $route); $route = new Route('/another/{thing}/about/{item}'); $collection->add('route_d', $route); $route = new Route('/path/add/one'); - $route->setRequirement('_method', 'GET|HEAD'); + $route->setMethods(['GET', 'HEAD']); $collection->add('route_e', $route); return $collection; @@ -152,12 +152,12 @@ public function contentRouteCollection() { $collection = new RouteCollection(); $route = new Route('path/three'); - $route->setRequirement('_method', 'POST'); + $route->setMethods(['POST']); $route->setRequirement('_content_type_format', 'json'); $collection->add('route_f', $route); $route = new Route('path/three'); - $route->setRequirement('_method', 'PATCH'); + $route->setMethods(['PATCH']); $route->setRequirement('_content_type_format', 'xml'); $collection->add('route_g', $route); return $collection; diff --git a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php index 4685727..677d214 100644 --- a/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php +++ b/core/tests/Drupal/Tests/Core/Routing/UrlGeneratorTest.php @@ -70,7 +70,7 @@ protected function setUp() { $first_route = new Route('/test/one'); $second_route = new Route('/test/two/{narf}'); $third_route = new Route('/test/two/'); - $fourth_route = new Route('/test/four', array(), array('_scheme' => 'https')); + $fourth_route = new Route('/test/four', array(), array(), array(), '', ['https']); $routes->add('test_1', $first_route); $routes->add('test_2', $second_route); $routes->add('test_3', $third_route);