Use the count method on the Collection

This commit is contained in:
Oliver Davies 2025-05-12 08:31:19 +01:00
parent 1013305d38
commit 58740872fa

View file

@ -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;
}
}