core/includes/common.inc | 5 +- core/lib/Drupal/Core/Asset/AssetResolver.php | 58 +++++++--------------- .../views_ui/src/Form/Ajax/ViewsFormBase.php | 4 +- 3 files changed, 22 insertions(+), 45 deletions(-) diff --git a/core/includes/common.inc b/core/includes/common.inc index bafec9d..27c9c54 100644 --- a/core/includes/common.inc +++ b/core/includes/common.inc @@ -932,8 +932,10 @@ function drupal_merge_attached(array $a, array $b) { * The structured array describing the data being rendered. * * @see drupal_render() - * * @see \Drupal\Core\Asset\AssetResolver + * + * @throws LogicException + * When attaching something of a non-existing attachment type. */ function drupal_process_attached(array $elements) { // Asset attachments are handled by \Drupal\Core\Asset\AssetResolver. @@ -942,7 +944,6 @@ function drupal_process_attached(array $elements) { } // Add additional types of attachments specified in the render() structure. - // Libraries, and drupalSettings require special handling. foreach ($elements['#attached'] as $callback => $options) { foreach ($elements['#attached'][$callback] as $args) { // Limit the amount allowed entries. diff --git a/core/lib/Drupal/Core/Asset/AssetResolver.php b/core/lib/Drupal/Core/Asset/AssetResolver.php index 7b96a18..8d60d55 100644 --- a/core/lib/Drupal/Core/Asset/AssetResolver.php +++ b/core/lib/Drupal/Core/Asset/AssetResolver.php @@ -44,30 +44,6 @@ class AssetResolver implements AssetResolverInterface { protected $themeManager; /** - * $libraries, along with all the depended asset libraries. - * - * @var string[] - */ - protected $librariesWithDependencies = []; - - /** - * $alreadyLoadedLibraries, along with all the depended asset libraries. - * - * @var string[] - */ - protected $alreadyLoadedLibrariesWithDependencies = []; - - /** - * Static cache of the JavaScript assets attached to the current response. - * - * @see reset() - * @see getJsAssets() - * - * @var array - */ - protected $jsAssets = NULL; - - /** * Constructs a new AssetResolver instance. * * @param \Drupal\Core\Asset\LibraryDiscoveryInterface $library_discovery @@ -87,7 +63,7 @@ public function __construct(LibraryDiscoveryInterface $library_discovery, Librar } /** - * Given lists of needed & loaded libraries, resolve which libraries to load. + * Given lists of needed & loaded libraries, resolves which libraries to load. * * For example, with core/a depending on core/c and core/b on core/d: * @code @@ -102,13 +78,13 @@ public function __construct(LibraryDiscoveryInterface $library_discovery, Librar * @return string[] * A list of libraries, in the order they should be loaded, including their * dependencies. (Any libraries that have already been loaded, and their - * dependencies, are excluded.) + * dependencies, are excluded.) */ protected function getLibrariesToLoad(AttachedAssetsInterface $assets) { return array_diff( $this->libraryDependencyResolver->getLibrariesWithDependencies($assets->getLibraries()), $this->libraryDependencyResolver->getLibrariesWithDependencies($assets->getAlreadyLoadedLibraries()) - ); + ); } /** @@ -143,7 +119,8 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) { $options['preprocess'] = FALSE; } - // Always add a tiny value to the weight, to conserve the insertion order. + // Always add a tiny value to the weight, to conserve the insertion + // order. $options['weight'] += count($css) / 1000; // Add the data to the CSS array depending on the type. @@ -159,8 +136,8 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) { break; default: - // External files are keyed by their full URI, so the same CSS file is - // not added twice. + // External files are keyed by their full URI, so the same CSS + // file is not added twice. $css[$options['data']] = $options; } } @@ -201,17 +178,15 @@ public function getCssAssets(AttachedAssetsInterface $assets, $optimize) { /** * Returns the JavaScript settings assets for this response's libraries. * - * Gathers all drupalSettings from all libraries in the current response and - * merges them, then it merges individual attached settings (provided by - * setSettings()) and finally invokes hook_js_settings_alter() to allow - * alterations of JavaScript settings by modules and themes. + * Gathers all drupalSettings from all libraries in the attached assets + * collection and merges them, then it merges individual attached settings, + * and finally invokes hook_js_settings_alter() to allow alterations of + * JavaScript settings by modules and themes. * * @param \Drupal\Core\Asset\AttachedAssetsInterface $assets * The assets attached to the current response. * @return array * A (possibly optimized) collection of JavaScript assets. - * - * @see ::setSettings() */ protected function getJsSettingsAssets(AttachedAssetsInterface $assets) { $settings = []; @@ -234,7 +209,6 @@ protected function getJsSettingsAssets(AttachedAssetsInterface $assets) { return $settings; } - /** * {@inheritdoc} */ @@ -259,14 +233,16 @@ public function getJsAssets(AttachedAssetsInterface $assets, $optimize) { 'browsers' => array(), ); - // Preprocess can only be set if caching is enabled and no attributes are set. + // Preprocess can only be set if caching is enabled and no attributes + // are set. $options['preprocess'] = $options['cache'] && empty($options['attributes']) ? $options['preprocess'] : FALSE; - // Always add a tiny value to the weight, to conserve the insertion order. + // Always add a tiny value to the weight, to conserve the insertion + // order. $options['weight'] += count($javascript) / 1000; - // Local and external files must keep their name as the associative key - // so the same JavaScript file is not added twice. + // Local and external files must keep their name as the associative + // key so the same JavaScript file is not added twice. $javascript[$options['data']] = $options; } } diff --git a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php index 32a3a89..6dd609e 100644 --- a/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php +++ b/core/modules/views_ui/src/Form/Ajax/ViewsFormBase.php @@ -214,8 +214,8 @@ protected function ajaxFormWrapper($form_class, FormStateInterface &$form_state) // Ajax command list to execute. $response = new AjaxResponse(); - // Attach the library necessary for using the OpenModalDialogCommand and set - // the attachments for this Ajax response. + // Attach the library necessary for using the OpenModalDialogCommand and + // set the attachments for this Ajax response. $form['#attached']['library'][] = 'core/drupal.dialog.ajax'; $response->setAttachments($form['#attached']);