This commit is contained in:
Oliver Davies 2025-06-17 23:10:04 +01:00
parent f08fb4cd67
commit fc4121e776

View file

@ -6,24 +6,26 @@ namespace Drupal\opd_presentations\Repository;
use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\node\NodeInterface; use Drupal\node\NodeInterface;
use Drupal\node\NodeStorageInterface;
use Drupal\opd_presentations\Presentation; use Drupal\opd_presentations\Presentation;
final class PresentationNodeRepository implements PresentationRepositoryInterface { final class PresentationNodeRepository implements PresentationRepositoryInterface {
public function __construct(private EntityTypeManagerInterface $entityTypeManager) { private NodeStorageInterface $nodeStorage;
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->nodeStorage = $entityTypeManager->getStorage('node');
} }
public function getPublished(): array { public function getPublished(): array {
$nodeStorage = $this->entityTypeManager->getStorage('node'); $query = $this->nodeStorage->getQuery();
$query = $nodeStorage->getQuery();
$query->accessCheck(); $query->accessCheck();
$query->condition('status', NodeInterface::PUBLISHED); $query->condition('status', NodeInterface::PUBLISHED);
$query->condition('type', Presentation::NODE_TYPE); $query->condition('type', Presentation::NODE_TYPE);
$nodeIds = $query->execute(); $nodeIds = $query->execute();
return $nodeStorage->loadMultiple($nodeIds); return $this->nodeStorage->loadMultiple($nodeIds);
} }
} }