From fc4121e77630bd530a684cc9566f6b284cc78461 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 17 Jun 2025 23:10:04 +0100 Subject: [PATCH] Refactor --- .../src/Repository/PresentationNodeRepository.php | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/modules/opd_presentations/src/Repository/PresentationNodeRepository.php b/modules/opd_presentations/src/Repository/PresentationNodeRepository.php index 8cf4ef3bd..b61dc811f 100644 --- a/modules/opd_presentations/src/Repository/PresentationNodeRepository.php +++ b/modules/opd_presentations/src/Repository/PresentationNodeRepository.php @@ -6,24 +6,26 @@ namespace Drupal\opd_presentations\Repository; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\node\NodeInterface; +use Drupal\node\NodeStorageInterface; use Drupal\opd_presentations\Presentation; 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 { - $nodeStorage = $this->entityTypeManager->getStorage('node'); - - $query = $nodeStorage->getQuery(); + $query = $this->nodeStorage->getQuery(); $query->accessCheck(); $query->condition('status', NodeInterface::PUBLISHED); $query->condition('type', Presentation::NODE_TYPE); $nodeIds = $query->execute(); - return $nodeStorage->loadMultiple($nodeIds); + return $this->nodeStorage->loadMultiple($nodeIds); } }