From 529eb1458e8c599389768c126ff639e689f70144 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Wed, 17 Jan 2024 10:57:16 +0000 Subject: [PATCH] Update Builder logic to set the node status --- web/modules/custom/example/src/Builder/PostBuilder.php | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/web/modules/custom/example/src/Builder/PostBuilder.php b/web/modules/custom/example/src/Builder/PostBuilder.php index d077e55..1ed5ac4 100644 --- a/web/modules/custom/example/src/Builder/PostBuilder.php +++ b/web/modules/custom/example/src/Builder/PostBuilder.php @@ -12,15 +12,21 @@ final class PostBuilder { private string $title; + private bool $isPublished = TRUE; + public static function create(): self { return new self(); } public function isNotPublished(): self { + $this->isPublished = FALSE; + return $this; } public function isPublished(): self { + $this->isPublished = TRUE; + return $this; } @@ -38,6 +44,7 @@ final class PostBuilder { public function getPost(): NodeInterface { $post = Node::create([ + 'status' => $this->isPublished, 'title' => $this->title, 'type' => 'post', ]);