Issue #2011832 by linclark: Change structure of REST config.
parent
03d3cb0a36
commit
7f2133b487
|
@ -75,7 +75,7 @@ class RouteSubscriber implements EventSubscriberInterface {
|
||||||
// If there is no format requirement or if it matches the
|
// If there is no format requirement or if it matches the
|
||||||
// configuration also add the route.
|
// configuration also add the route.
|
||||||
$format_requirement = $route->getRequirement('_format');
|
$format_requirement = $route->getRequirement('_format');
|
||||||
if (!$format_requirement || isset($enabled_methods[$method][$format_requirement])) {
|
if (!$format_requirement || empty($enabled_methods[$method]['supported_formats']) || in_array($format_requirement, $enabled_methods[$method]['supported_formats'])) {
|
||||||
$collection->add("rest.$name", $route);
|
$collection->add("rest.$name", $route);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,8 +51,8 @@ class RequestHandler extends ContainerAware {
|
||||||
// format. If the serializer cannot handle it an exception will be thrown
|
// format. If the serializer cannot handle it an exception will be thrown
|
||||||
// that bubbles up to the client.
|
// that bubbles up to the client.
|
||||||
$config = $this->container->get('config.factory')->get('rest.settings')->get('resources');
|
$config = $this->container->get('config.factory')->get('rest.settings')->get('resources');
|
||||||
$enabled_formats = $config[$plugin][$request->getMethod()];
|
$method_settings = $config[$plugin][$request->getMethod()];
|
||||||
if (empty($enabled_formats) || isset($enabled_formats[$format])) {
|
if (empty($method_settings['supported_formats']) || in_array($format, $method_settings['supported_formats'])) {
|
||||||
$definition = $resource->getPluginDefinition();
|
$definition = $resource->getPluginDefinition();
|
||||||
$class = $definition['serialization_class'];
|
$class = $definition['serialization_class'];
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -195,7 +195,7 @@ abstract class RESTTestBase extends WebTestBase {
|
||||||
$settings = array();
|
$settings = array();
|
||||||
if ($resource_type) {
|
if ($resource_type) {
|
||||||
if ($format) {
|
if ($format) {
|
||||||
$settings[$resource_type][$method][$format] = 'TRUE';
|
$settings[$resource_type][$method]['supported_formats'][] = $format;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$settings[$resource_type][$method] = array();
|
$settings[$resource_type][$method] = array();
|
||||||
|
|
Loading…
Reference in New Issue