diff --git a/CHANGELOG.md b/CHANGELOG.md index 468f8d7b..12586902 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ See [keep a changelog] for information about writing changes to this log. ## [Unreleased] +* [PR-19](https://github.com/itk-dev/giv-din-stemme/pull/19) + Only get published texts. * [PR-16](https://github.com/itk-dev/giv-din-stemme/pull/16) Development OIDC fixes * [PR-13](https://github.com/itk-dev/giv-din-stemme/pull/13) diff --git a/web/modules/custom/giv_din_stemme/src/Controller/GivDinStemmeController.php b/web/modules/custom/giv_din_stemme/src/Controller/GivDinStemmeController.php index dfb9fced..be10bffa 100644 --- a/web/modules/custom/giv_din_stemme/src/Controller/GivDinStemmeController.php +++ b/web/modules/custom/giv_din_stemme/src/Controller/GivDinStemmeController.php @@ -175,7 +175,7 @@ public function thankYou(Request $request): array { * and redirects to the first. */ public function startDonating(Request $request): RedirectResponse { - $text = $this->helper->getRandomText(); + $text = $this->helper->getRandomPublishedText(); $collectionId = $this->helper->generateUuid(); $delta = 0; diff --git a/web/modules/custom/giv_din_stemme/src/Helper/Helper.php b/web/modules/custom/giv_din_stemme/src/Helper/Helper.php index 706cc92f..48d9a65b 100644 --- a/web/modules/custom/giv_din_stemme/src/Helper/Helper.php +++ b/web/modules/custom/giv_din_stemme/src/Helper/Helper.php @@ -44,12 +44,13 @@ public function getFrontpageValues(): array { } /** - * Gets random Text. + * Gets random published Text. */ - public function getRandomText(): EntityInterface { + public function getRandomPublishedText(): EntityInterface { $nodes = $this->entityTypeManager->getStorage('node')->loadByProperties([ 'type' => 'text', + 'status' => 1, ]); $count = count($nodes);