Mercurial > hg > isophonics-drupal-site
comparison core/modules/rest/src/Routing/ResourceRoutes.php @ 17:129ea1e6d783
Update, including to Drupal core 8.6.10
author | Chris Cannam |
---|---|
date | Thu, 28 Feb 2019 13:21:36 +0000 |
parents | 1fec387a4317 |
children | af1871eacc83 |
comparison
equal
deleted
inserted
replaced
16:c2387f117808 | 17:129ea1e6d783 |
---|---|
119 } | 119 } |
120 } | 120 } |
121 | 121 |
122 // The configuration has been validated, so we update the route to: | 122 // The configuration has been validated, so we update the route to: |
123 // - set the allowed response body content types/formats for methods | 123 // - set the allowed response body content types/formats for methods |
124 // that may send response bodies | 124 // that may send response bodies (unless hardcoded by the plugin) |
125 // - set the allowed request body content types/formats for methods that | 125 // - set the allowed request body content types/formats for methods that |
126 // allow request bodies to be sent | 126 // allow request bodies to be sent (unless hardcoded by the plugin) |
127 // - set the allowed authentication providers | 127 // - set the allowed authentication providers |
128 if (in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'PATCH'], TRUE)) { | 128 if (in_array($method, ['GET', 'HEAD', 'POST', 'PUT', 'PATCH'], TRUE) && !$route->hasRequirement('_format')) { |
129 $route->addRequirements(['_format' => implode('|', $rest_resource_config->getFormats($method))]); | 129 $route->addRequirements(['_format' => implode('|', $rest_resource_config->getFormats($method))]); |
130 } | 130 } |
131 if (in_array($method, ['POST', 'PATCH', 'PUT'], TRUE)) { | 131 if (in_array($method, ['POST', 'PATCH', 'PUT'], TRUE) && !$route->hasRequirement('_content_type_format')) { |
132 $route->addRequirements(['_content_type_format' => implode('|', $rest_resource_config->getFormats($method))]); | 132 $route->addRequirements(['_content_type_format' => implode('|', $rest_resource_config->getFormats($method))]); |
133 } | 133 } |
134 $route->setOption('_auth', $rest_resource_config->getAuthenticationProviders($method)); | 134 $route->setOption('_auth', $rest_resource_config->getAuthenticationProviders($method)); |
135 $route->setDefault('_rest_resource_config', $rest_resource_config->id()); | 135 $route->setDefault('_rest_resource_config', $rest_resource_config->id()); |
136 $parameters = $route->getOption('parameters') ?: []; | 136 $parameters = $route->getOption('parameters') ?: []; |