Refactor
This commit is contained in:
parent
fc4121e776
commit
8a480121d2
1 changed files with 9 additions and 3 deletions
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue