From 8a480121d203ca6f51310f952b15cfa09080b034 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 17 Jun 2025 23:31:49 +0100 Subject: [PATCH] Refactor --- .../src/Repository/PresentationNodeRepository.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/modules/opd_presentations/src/Repository/PresentationNodeRepository.php b/modules/opd_presentations/src/Repository/PresentationNodeRepository.php index b61dc811f..d9340e21e 100644 --- a/modules/opd_presentations/src/Repository/PresentationNodeRepository.php +++ b/modules/opd_presentations/src/Repository/PresentationNodeRepository.php @@ -5,6 +5,7 @@ declare(strict_types=1); namespace Drupal\opd_presentations\Repository; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\Core\Entity\Query\QueryInterface; use Drupal\node\NodeInterface; use Drupal\node\NodeStorageInterface; use Drupal\opd_presentations\Presentation; @@ -18,14 +19,19 @@ final class PresentationNodeRepository implements PresentationRepositoryInterfac } public function getPublished(): array { - $query = $this->nodeStorage->getQuery(); - $query->accessCheck(); + $query = $this->query(); $query->condition('status', NodeInterface::PUBLISHED); - $query->condition('type', Presentation::NODE_TYPE); $nodeIds = $query->execute(); return $this->nodeStorage->loadMultiple($nodeIds); } + private function query(): QueryInterface { + $query = $this->nodeStorage->getQuery(); + $query->accessCheck(); + $query->condition('type', Presentation::NODE_TYPE); + + return $query; + } }