Make the email count dynamic based on the number

...of daily email nodes
This commit is contained in:
Oliver Davies 2025-05-12 01:13:25 +01:00
parent 6ba4b80645
commit c48f8acd4a
9 changed files with 5666 additions and 5 deletions

View file

@ -0,0 +1,32 @@
<?php
declare(strict_types=1);
namespace Drupal\opd_daily_emails\Repository;
use Drupal\Core\Entity\EntityTypeManagerInterface;
final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
public function __construct(
public readonly EntityTypeManagerInterface $entityTypeManager,
) {
}
public function getAll(): array {
$query = $this->entityTypeManager
->getStorage('node')
->getQuery();
// TODO: add condition for published status. Only return published nodes.
$query->condition('type', 'daily_email');
$query->accessCheck(TRUE);
$result = $query->execute();
// TODO: this returns a list of node IDs. Load and return the nodes.
return $result;
}
}

View file

@ -0,0 +1,11 @@
<?php
declare(strict_types=1);
namespace Drupal\opd_daily_emails\Repository;
interface DailyEmailRepositoryInterface {
public function getAll(): array;
}