oliverdavies.uk/modules/opd_presentations/src/Repository/PresentationNodeRepository.php

32 lines
852 B
PHP
Raw Normal View History

2025-06-16 22:17:33 +01:00
<?php
declare(strict_types=1);
namespace Drupal\opd_presentations\Repository;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\node\NodeInterface;
2025-06-17 23:10:04 +01:00
use Drupal\node\NodeStorageInterface;
2025-06-16 22:17:33 +01:00
use Drupal\opd_presentations\Presentation;
final class PresentationNodeRepository implements PresentationRepositoryInterface {
2025-06-17 23:10:04 +01:00
private NodeStorageInterface $nodeStorage;
public function __construct(EntityTypeManagerInterface $entityTypeManager) {
$this->nodeStorage = $entityTypeManager->getStorage('node');
2025-06-16 22:17:33 +01:00
}
public function getPublished(): array {
2025-06-17 23:10:04 +01:00
$query = $this->nodeStorage->getQuery();
2025-06-16 22:17:33 +01:00
$query->accessCheck();
$query->condition('status', NodeInterface::PUBLISHED);
$query->condition('type', Presentation::NODE_TYPE);
$nodeIds = $query->execute();
2025-06-17 23:10:04 +01:00
return $this->nodeStorage->loadMultiple($nodeIds);
2025-06-16 22:17:33 +01:00
}
}