Commit 7f2133b4 authored by alexpott's avatar alexpott

Issue #2011832 by linclark: Change structure of REST config.

parent 03d3cb0a
......@@ -75,7 +75,7 @@ public function dynamicRoutes(RouteBuildEvent $event) {
// If there is no format requirement or if it matches the
// configuration also add the route.
$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);
}
}
......
......@@ -51,8 +51,8 @@ public function handle(Request $request, $id = NULL) {
// format. If the serializer cannot handle it an exception will be thrown
// that bubbles up to the client.
$config = $this->container->get('config.factory')->get('rest.settings')->get('resources');
$enabled_formats = $config[$plugin][$request->getMethod()];
if (empty($enabled_formats) || isset($enabled_formats[$format])) {
$method_settings = $config[$plugin][$request->getMethod()];
if (empty($method_settings['supported_formats']) || in_array($format, $method_settings['supported_formats'])) {
$definition = $resource->getPluginDefinition();
$class = $definition['serialization_class'];
try {
......
......@@ -195,7 +195,7 @@ protected function enableService($resource_type, $method = 'GET', $format = NULL
$settings = array();
if ($resource_type) {
if ($format) {
$settings[$resource_type][$method][$format] = 'TRUE';
$settings[$resource_type][$method]['supported_formats'][] = $format;
}
else {
$settings[$resource_type][$method] = array();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment