36 lines
805 B
PHP
36 lines
805 B
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Drupal\opd_daily_emails;
|
|
|
|
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
|
use Drupal\node\NodeInterface;
|
|
|
|
final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
|
|
|
public function __construct(
|
|
public readonly EntityTypeManagerInterface $entityTypeManager,
|
|
) {
|
|
}
|
|
|
|
public function getAll(): DailyEmails {
|
|
$nodeStorage = $this->entityTypeManager
|
|
->getStorage('node');
|
|
|
|
$query = $nodeStorage->getQuery();
|
|
|
|
$query->condition('status', NodeInterface::PUBLISHED);
|
|
$query->condition('type', 'daily_email');
|
|
|
|
$query->accessCheck(TRUE);
|
|
|
|
$nodeIds = $query->execute();
|
|
|
|
/** @var NodeInterface[] */
|
|
$nodes = $nodeStorage->loadMultiple($nodeIds);
|
|
|
|
return DailyEmails::fromEmails($nodes);
|
|
}
|
|
|
|
}
|