From 92ca0647373adf89d7f720e0601b5bae9d4fc4bb Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Thu, 19 Mar 2020 21:35:26 +0000 Subject: [PATCH] 4i: Update getAll() method Ensure that only published articles are returned from the `getAll()` method on the article repository. --- .../custom/my_module/src/Repository/ArticleRepository.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/web/modules/custom/my_module/src/Repository/ArticleRepository.php b/web/modules/custom/my_module/src/Repository/ArticleRepository.php index 3da6051..54b0dc5 100644 --- a/web/modules/custom/my_module/src/Repository/ArticleRepository.php +++ b/web/modules/custom/my_module/src/Repository/ArticleRepository.php @@ -3,6 +3,7 @@ namespace Drupal\my_module\Repository; use Drupal\Core\Entity\EntityTypeManagerInterface; +use Drupal\node\NodeInterface; class ArticleRepository { @@ -17,6 +18,7 @@ class ArticleRepository { public function getAll(): array { return $this->nodeStorage->loadByProperties([ + 'status' => NodeInterface::PUBLISHED, 'type' => 'article', ]); }