Return the email nodes, not just the node IDs
This commit is contained in:
parent
7e32227e7d
commit
1013305d38
4 changed files with 44 additions and 9 deletions
|
@ -6,6 +6,7 @@ namespace Drupal\opd_daily_emails\Repository;
|
|||
|
||||
use Drupal\Core\Entity\EntityTypeManagerInterface;
|
||||
use Drupal\node\NodeInterface;
|
||||
use Drupal\opd_daily_emails\Collection\DailyEmailCollection;
|
||||
|
||||
final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
||||
|
||||
|
@ -14,20 +15,21 @@ final class DailyEmailNodeRepository implements DailyEmailRepositoryInterface {
|
|||
) {
|
||||
}
|
||||
|
||||
public function getAll(): array {
|
||||
$query = $this->entityTypeManager
|
||||
->getStorage('node')
|
||||
->getQuery();
|
||||
public function getAll(): DailyEmailCollection {
|
||||
$nodeStorage = $this->entityTypeManager
|
||||
->getStorage('node');
|
||||
|
||||
$query = $nodeStorage->getQuery();
|
||||
|
||||
$query->condition('status', NodeInterface::PUBLISHED);
|
||||
$query->condition('type', 'daily_email');
|
||||
|
||||
$query->accessCheck(TRUE);
|
||||
|
||||
$result = $query->execute();
|
||||
$nodeIds = $query->execute();
|
||||
$nodes = $nodeStorage->loadMultiple($nodeIds);
|
||||
|
||||
// TODO: this returns a list of node IDs. Load and return the nodes.
|
||||
return $result;
|
||||
return new DailyEmailCollection($nodes);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue