Issue #3441920 by scott_euser, catch, smustgrave, quietone: Support #attached settings in ViewAjaxController

(cherry picked from commit 3e486f783a)
merge-requests/7931/head
Alex Pott 2024-05-05 21:50:14 +01:00
parent 6bca41b201
commit 12097985d8
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
2 changed files with 20 additions and 1 deletions

View File

@ -214,6 +214,10 @@ class ViewAjaxController implements ContainerInjectionInterface {
$response->addCommand(new PrependCommand(".js-view-dom-id-$dom_id", ['#type' => 'status_messages']));
$request->query->set('ajax_page_state', $existing_page_state);
if (!empty($preview['#attached'])) {
$response->setAttachments($preview['#attached']);
}
return $response;
}
else {

View File

@ -209,6 +209,14 @@ class ViewAjaxControllerTest extends UnitTestCase {
$this->assertSame($response->getView(), $executable);
$this->assertViewResultCommand($response);
// Test that the ajax controller for Views contains the
// Drupal Settings.
$this->assertEquals([
'drupalSettings' => [
'testSetting' => ['Setting'],
],
], $response->getAttachments());
}
/**
@ -389,7 +397,14 @@ class ViewAjaxControllerTest extends UnitTestCase {
->willReturn(TRUE);
$executable->expects($this->atMost(1))
->method('preview')
->willReturn(['#markup' => 'View result']);
->willReturn([
'#markup' => 'View result',
'#attached' => [
'drupalSettings' => [
'testSetting' => ['Setting'],
],
],
]);
$this->executableFactory->expects($this->once())
->method('get')