Commit 2ca39a47 authored by alexpott's avatar alexpott

Issue #2452475 by lhangea, googletorp, arpitr, neetu morwani, ianthomas_uk,...

Issue #2452475 by lhangea, googletorp, arpitr, neetu morwani, ianthomas_uk, Mile23: Remove deprecated function drupal_merge_attached() and its references
parent 887b1e4c
......@@ -542,55 +542,6 @@ function drupal_js_defaults($data = NULL) {
);
}
/**
* 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 <SCRIPT> tags, the value of drupalSettings.foo is
* // ['d', 'b', 'c'], not ['a', 'b', 'c', 'd'].
* @endcode
*
* By following jQuery.extend() merge logic rather than common PHP array merge
* logic, the following are ensured:
* - Attaching JavaScript settings is idempotent: attaching the same settings
* twice does not change the output sent to the browser.
* - If pieces of the page are rendered in separate PHP requests and the
* returned settings are merged by JavaScript, the resulting settings are the
* same as if rendered in one PHP request and merged by PHP.
*
* @param array $a
* An #attached array.
* @param array $b
* Another #attached array.
*
* @return array
* The merged #attached array.
*
* @deprecated To be removed in Drupal 8.0.x. Use
* \Drupal\Core\Render\BubbleableMetadata::mergeAttachments() instead.
*/
function drupal_merge_attached(array $a, array $b) {
return BubbleableMetadata::mergeAttachments($a, $b);
}
/**
* Processes non-asset attachments in a render() structure.
*
......@@ -1057,7 +1008,7 @@ function drupal_pre_render_links($element) {
}
// Merge attachments.
if (isset($child['#attached'])) {
$element['#attached'] = drupal_merge_attached($element['#attached'], $child['#attached']);
$element['#attached'] = BubbleableMetadata::mergeAttachments($element['#attached'], $child['#attached']);
}
}
return $element;
......
......@@ -10,6 +10,7 @@
use Drupal\editor\Entity\Editor;
use Drupal\filter\Entity\FilterFormat;
use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Render\BubbleableMetadata;
/**
* Defines a service for Text Editor's render elements.
......@@ -93,7 +94,7 @@ function preRenderTextFormat(array $element) {
$element['#attached']['library'][] = 'editor/drupal.editor';
// Attach attachments for all available editors.
$element['#attached'] = drupal_merge_attached($element['#attached'], $this->pluginManager->getAttachments($format_ids));
$element['#attached'] = BubbleableMetadata::mergeAttachments($element['#attached'], $this->pluginManager->getAttachments($format_ids));
// Apply XSS filters when editing content if necessary. Some types of text
// editors cannot guarantee that the end user won't become a victim of XSS.
......
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