Loading toastr.module +10 −5 Changes for toastr.module: 10 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -5,6 +5,13 @@ use Drupal\toastr\Form\ToastrSettingsForm; * Implements hook_page_attachments(). */ function toastr_page_attachments(array &$attachments) { $attachments['#attached']['library'][] = 'toastr/messages'; } /** * Implements hook_js_settings_alter(). */ function toastr_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets) { // Get all the Drupal status messages, so they do not appear anywhere else. $messages = \Drupal::messenger()->deleteAll(); if (!empty($messages)) { Loading @@ -16,10 +23,8 @@ function toastr_page_attachments(array &$attachments) { foreach ($keys as $key) { $settings[$key] = is_null($config->get($key)) ? $default_settings[$key] : $config->get($key); } $attachments['#attached']['drupalSettings']['toastr'] = []; $attachments['#attached']['drupalSettings']['toastr']['messages'] = $messages; $attachments['#attached']['drupalSettings']['toastr']['settings'] = $settings; // Unconditionally attach an asset to the page. $attachments['#attached']['library'][] = 'toastr/messages'; $settings['toastr'] = []; $settings['toastr']['messages'] = $messages; $settings['toastr']['settings'] = $settings; } } Loading
toastr.module +10 −5 Changes for toastr.module: 10 added lines, 5 removed lines. Original line number Diff line number Diff line Loading @@ -5,6 +5,13 @@ use Drupal\toastr\Form\ToastrSettingsForm; * Implements hook_page_attachments(). */ function toastr_page_attachments(array &$attachments) { $attachments['#attached']['library'][] = 'toastr/messages'; } /** * Implements hook_js_settings_alter(). */ function toastr_js_settings_alter(array &$settings, \Drupal\Core\Asset\AttachedAssetsInterface $assets) { // Get all the Drupal status messages, so they do not appear anywhere else. $messages = \Drupal::messenger()->deleteAll(); if (!empty($messages)) { Loading @@ -16,10 +23,8 @@ function toastr_page_attachments(array &$attachments) { foreach ($keys as $key) { $settings[$key] = is_null($config->get($key)) ? $default_settings[$key] : $config->get($key); } $attachments['#attached']['drupalSettings']['toastr'] = []; $attachments['#attached']['drupalSettings']['toastr']['messages'] = $messages; $attachments['#attached']['drupalSettings']['toastr']['settings'] = $settings; // Unconditionally attach an asset to the page. $attachments['#attached']['library'][] = 'toastr/messages'; $settings['toastr'] = []; $settings['toastr']['messages'] = $messages; $settings['toastr']['settings'] = $settings; } }