diff --git a/core/core.services.yml b/core/core.services.yml index 6127c8f..3bae441 100644 --- a/core/core.services.yml +++ b/core/core.services.yml @@ -568,7 +568,7 @@ services: class: Symfony\Component\HttpKernel\HttpKernel arguments: ['@event_dispatcher', '@controller_resolver', '@request_stack'] http_negotiation.format_negotiator: - class: Drupal\Core\ContentNegotiation + class: Drupal\Core\FormatMapping private: true http_middleware.negotiation: class: Drupal\Core\StackMiddleware\NegotiationMiddleware diff --git a/core/lib/Drupal/Core/FormatMapping.php b/core/lib/Drupal/Core/FormatMapping.php index 1248a69..3b3166c 100644 --- a/core/lib/Drupal/Core/FormatMapping.php +++ b/core/lib/Drupal/Core/FormatMapping.php @@ -36,12 +36,15 @@ public function getContentType(Request $request) { return 'iframeupload'; } + if ($type = $request->query->get('dataType')) { + return 'drupal_' . $type; + } + // Check all formats, if priority format is found return it. $first_found_format = FALSE; - $priority = array('html', 'drupal_ajax', 'drupal_modal', 'drupal_dialog'); foreach ($request->getAcceptableContentTypes() as $mime_type) { $format = $request->getFormat($mime_type); - if (in_array($format, $priority, TRUE)) { + if ($format === 'html') { return $format; } if (!is_null($format) && !$first_found_format) { diff --git a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php index 295857d..8fa0173 100644 --- a/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php +++ b/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php @@ -7,7 +7,7 @@ namespace Drupal\Core\StackMiddleware; -use Drupal\Core\ContentNegotiation; +use Drupal\Core\FormatMapping; use Drupal\Core\ContentNegotiationInterface; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpKernel\HttpKernelInterface; @@ -29,7 +29,7 @@ class NegotiationMiddleware implements HttpKernelInterface { /** * The content negotiator. * - * @var \Drupal\Core\ContentNegotiation + * @var \Drupal\Core\FormatMapping */ protected $negotiator; @@ -45,10 +45,10 @@ class NegotiationMiddleware implements HttpKernelInterface { * * @param \Symfony\Component\HttpKernel\HttpKernelInterface $app * The wrapper HTTP kernel - * @param \Drupal\Core\ContentNegotiation $negotiator + * @param \Drupal\Core\FormatMapping $negotiator * The content negotiator. */ - public function __construct(HttpKernelInterface $app, ContentNegotiation $negotiator) { + public function __construct(HttpKernelInterface $app, FormatMapping $negotiator) { $this->app = $app; $this->negotiator = $negotiator; } diff --git a/core/misc/ajax.js b/core/misc/ajax.js index 5b64318..c788c16 100644 --- a/core/misc/ajax.js +++ b/core/misc/ajax.js @@ -255,7 +255,7 @@ ajax.options.data.dialogOptions = element_settings.dialog; } if (element_settings.dialogType) { - ajax.options.data.dialogType = element_settings.dialogType; + ajax.options.url += '?dataType=' + element_settings.dialogType; } // Bind the ajaxSubmit function to the element event. diff --git a/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php b/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php index e411008..36921e8 100644 --- a/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php +++ b/core/tests/Drupal/Tests/Core/ContentNegotiationTest.php @@ -7,18 +7,18 @@ namespace Drupal\Tests\Core; -use Drupal\Core\ContentNegotiation; +use Drupal\Core\FormatMapping; use Drupal\Tests\UnitTestCase; use Symfony\Component\HttpFoundation\Request; /** - * @coversDefaultClass \Drupal\Core\ContentNegotiation - * @group ContentNegotiation + * @coversDefaultClass \Drupal\Core\FormatMapping + * @group FormatMapping */ class ContentNegotiationTest extends UnitTestCase { /** - * @var \Drupal\Core\ContentNegotiation + * @var \Drupal\Core\FormatMapping */ protected $contentNegotiation; @@ -28,7 +28,7 @@ class ContentNegotiationTest extends UnitTestCase { protected function setUp() { parent::setUp(); - $this->contentNegotiation = new ContentNegotiation; + $this->contentNegotiation = new FormatMapping; } /**