Skip to content

Commit

Permalink
use use statement for stringTranslationTrait
Browse files Browse the repository at this point in the history
  • Loading branch information
a-frear committed Jan 31, 2024
1 parent 02ddc0a commit 4a12873
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/EventSubscriber/ViewsAjaxResponseSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -13,6 +14,8 @@
* Alter a Views Ajax Response.
*/
class ViewsAjaxResponseSubscriber implements EventSubscriberInterface {

use StringTranslationTrait;

/**
* {@inheritdoc}
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit 4a12873

Please sign in to comment.