From 58740872fa9e0679cec43f0822a7a1e4f959176c Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Mon, 12 May 2025 08:31:19 +0100 Subject: [PATCH] Use the `count` method on the Collection --- modules/opd_daily_emails/opd_daily_emails.module | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/modules/opd_daily_emails/opd_daily_emails.module b/modules/opd_daily_emails/opd_daily_emails.module index c780de12e..13fcc8067 100644 --- a/modules/opd_daily_emails/opd_daily_emails.module +++ b/modules/opd_daily_emails/opd_daily_emails.module @@ -3,6 +3,7 @@ declare(strict_types=1); use Drupal\Core\Render\BubbleableMetadata; +use Drupal\opd_daily_emails\Collection\DailyEmailCollection; use Drupal\opd_daily_emails\Repository\DailyEmailNodeRepository; /** @@ -43,7 +44,9 @@ function opd_daily_emails_tokens($type, $tokens, array $data, array $options, Bu case 'email-count': $dailyEmailRepository = \Drupal::service(DailyEmailNodeRepository::class); - $replacements[$original] = count($dailyEmailRepository->getAll()); + $dailyEmails = $dailyEmailRepository->getAll(); + + $replacements[$original] = $dailyEmails->count(); break; } }