33 lines
735 B
PHP
33 lines
735 B
PHP
|
<?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;
|
||
|
}
|
||
|
|
||
|
}
|