2024-01-16 09:54:33 +02:00

31 lines
605 B
PHP

<?php
namespace Drupal\builders_test;
use Drupal\node\Entity\Node;
class PageBuilder {
private Node $node;
private string $title = 'Title';
private string $languageCode = 'en';
public function __construct() {
$this->node = Node::create([
'type' => 'page',
'langcode' => $this->languageCode,
'title' => $this->title
]);
}
public static function create(): PageBuilder {
return new PageBuilder();
}
public function build(): Node {
$this->node->save();
return $this->node;
}
}