Refactor
Try a different way of naming and grouping classes.
This commit is contained in:
parent
52c1b33711
commit
6b6b362a49
15 changed files with 111 additions and 59 deletions
36
modules/opd_daily_emails/src/DailyEmailNodeRepository.php
Normal file
36
modules/opd_daily_emails/src/DailyEmailNodeRepository.php
Normal file
|
@ -0,0 +1,36 @@
|
|||
<?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::new($nodes);
|
||||
}
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue