From 4a128736f86511b26d5582334f3b9ac4625955a2 Mon Sep 17 00:00:00 2001 From: Amy Frear Date: Wed, 31 Jan 2024 15:51:58 -0500 Subject: [PATCH] use use statement for stringTranslationTrait --- src/EventSubscriber/ViewsAjaxResponseSubscriber.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/EventSubscriber/ViewsAjaxResponseSubscriber.php b/src/EventSubscriber/ViewsAjaxResponseSubscriber.php index 8389704..0eccc55 100644 --- a/src/EventSubscriber/ViewsAjaxResponseSubscriber.php +++ b/src/EventSubscriber/ViewsAjaxResponseSubscriber.php @@ -4,6 +4,7 @@ use Drupal\Core\Ajax\AnnounceCommand; use Drupal\Core\Ajax\FocusFirstCommand; +use Drupal\Core\StringTranslation\StringTranslationTrait; use Drupal\views\Ajax\ViewAjaxResponse; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpKernel\Event\FilterResponseEvent; @@ -13,6 +14,8 @@ * Alter a Views Ajax Response. */ class ViewsAjaxResponseSubscriber implements EventSubscriberInterface { + + use StringTranslationTrait; /** * {@inheritdoc} @@ -57,7 +60,7 @@ public function onResponse(FilterResponseEvent $event) { // Add in Announce for number of results. $result_count = count($view->result); // @todo variablise this in a settings page. - $msg = \Drupal::translation()->formatPlural($result_count, '1 result loaded.', '@count results loaded.'); + $msg = $this->formatPlural($result_count, '1 result loaded.', '@count results loaded.'); $response->addCommand(new AnnounceCommand($msg, 'assertive')); // Add in focus command.