core/includes/common.inc | 5 +- core/lib/Drupal/Core/Ajax/AjaxResponse.php | 3 +- .../Ajax/CommandWithAttachedAssetsInterface.php | 2 +- .../Core/Ajax/CommandWithAttachedAssetsTrait.php | 3 +- core/lib/Drupal/Core/Asset/AttachedAssets.php | 54 ---------------------- core/lib/Drupal/Core/Render/Renderer.php | 16 +++++++ core/lib/Drupal/Core/Render/RendererInterface.php | 44 ++++++++++++++++++ 7 files changed, 68 insertions(+), 59 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index 2731dc1..654723c 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -33,6 +33,7 @@ use Drupal\Core\Routing\GeneratorNotInitializedException; use Drupal\Core\Template\Attribute; use Drupal\Core\Render\Element; +use Drupal\Core\Render\Renderer; use Drupal\Core\Session\AnonymousUserSession; /** @@ -892,10 +893,10 @@ function drupal_js_defaults($data = NULL) { * The merged #attached array. * * @deprecated To be removed in Drupal 8.0.x. Use - * \Drupal\Core\Asset\AttachedAssets::mergeAttachments() instead. + * \Drupal\Core\Render\Renderer::mergeAttachments() instead. */ function drupal_merge_attached(array $a, array $b) { - return AttachedAssets::mergeAttachments($a, $b); + return Renderer::mergeAttachments($a, $b); } /** diff --git a/core/lib/Drupal/Core/Ajax/AjaxResponse.php b/core/lib/Drupal/Core/Ajax/AjaxResponse.php index 766026d..91ceeb4 100644 --- a/core/lib/Drupal/Core/Ajax/AjaxResponse.php +++ b/core/lib/Drupal/Core/Ajax/AjaxResponse.php @@ -8,6 +8,7 @@ namespace Drupal\Core\Ajax; use Drupal\Core\Asset\AttachedAssets; +use Drupal\Core\Render\Renderer; use Symfony\Component\HttpFoundation\JsonResponse; use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\Response; @@ -77,7 +78,7 @@ public function addCommand(CommandInterface $command, $prepend = FALSE) { 'library' => $assets->getLibraries(), 'drupalSettings' => $assets->getSettings(), ]; - $attachments = AttachedAssets::mergeAttachments($this->attachments, $attachments); + $attachments = Renderer::mergeAttachments($this->attachments, $attachments); $this->setAttachments($attachments); } diff --git a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsInterface.php b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsInterface.php index 5ba1fa2..f55ce6c 100644 --- a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsInterface.php +++ b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsInterface.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\Ajax\CommandWithAttachedAssetsInterface. + * Contains \Drupal\Core\Ajax\CommandWithAttachedAssetsInterface. */ namespace Drupal\Core\Ajax; diff --git a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php index c8e3b83..e3f31b9 100644 --- a/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php +++ b/core/lib/Drupal/Core/Ajax/CommandWithAttachedAssetsTrait.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\Ajax\CommandWithAttachedAssetsTrait. + * Contains \Drupal\Core\Ajax\CommandWithAttachedAssetsTrait. */ namespace Drupal\Core\Ajax; @@ -53,4 +53,5 @@ protected function getRenderedContent() { public function getAttachedAssets() { return $this->attachedAssets; } + } diff --git a/core/lib/Drupal/Core/Asset/AttachedAssets.php b/core/lib/Drupal/Core/Asset/AttachedAssets.php index f0ef5ec..d94618e 100644 --- a/core/lib/Drupal/Core/Asset/AttachedAssets.php +++ b/core/lib/Drupal/Core/Asset/AttachedAssets.php @@ -5,7 +5,6 @@ */ namespace Drupal\Core\Asset; -use Drupal\Component\Utility\NestedArray; /** * The default attached assets collection. @@ -52,59 +51,6 @@ public static function createFromRenderArray(array $render_array) { } /** - * Merges two #attached arrays. - * - * The values under the 'drupalSettings' key are merged in a special way, to - * match the behavior of - * - * @code - * jQuery.extend(true, {}, $settings_items[0], $settings_items[1], ...) - * @endcode - * - * This means integer indices are preserved just like string indices are, - * rather than re-indexed as is common in PHP array merging. - * - * Example: - * @code - * function module1_page_attachments(&$page) { - * $page['a']['#attached']['drupalSettings']['foo'] = ['a', 'b', 'c']; - * } - * function module2_page_attachments(&$page) { - * $page['#attached']['drupalSettings']['foo'] = ['d']; - * } - * // When the page is rendered after the above code, and the browser runs the - * // resulting