add text to node

This commit is contained in:
Yisroel Baum 2026-02-20 11:58:13 +02:00
parent e55133ceac
commit c0994d806e
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 17 additions and 0 deletions

View file

@ -2,9 +2,12 @@
namespace App\Node; namespace App\Node;
use App\Text\Text;
class CreateNodeDto class CreateNodeDto
{ {
public function __construct( public function __construct(
public Text $text,
public string $title, public string $title,
) {} ) {}
} }

View file

@ -2,14 +2,22 @@
namespace App\Node; namespace App\Node;
use App\Text\Text;
class Node class Node
{ {
public function __construct( public function __construct(
private string $title, private string $title,
private Text $text,
) {} ) {}
public function getTitle(): string public function getTitle(): string
{ {
return $this->title; return $this->title;
} }
public function getText(): Text
{
return $this->text;
}
} }

View file

@ -5,16 +5,20 @@ namespace App\Node\UseCases;
use App\Node\Node; use App\Node\Node;
use App\Node\CreateNodeDto; use App\Node\CreateNodeDto;
use App\Node\NodeRepository; use App\Node\NodeRepository;
use App\Text\TextRepository;
class CreateNode class CreateNode
{ {
public function __construct( public function __construct(
private NodeRepository $nodeRepo, private NodeRepository $nodeRepo,
private TextRepository $textRepo,
) {} ) {}
public function execute(CreateNodeRequest $request): Node public function execute(CreateNodeRequest $request): Node
{ {
$text = $this->textRepo->find($request->textId);
return $this->nodeRepo->create(new CreateNodeDto( return $this->nodeRepo->create(new CreateNodeDto(
text: $text,
title: $request->title, title: $request->title,
)); ));
} }

View file

@ -5,6 +5,7 @@ namespace App\Node\UseCases;
class CreateNodeRequest class CreateNodeRequest
{ {
public function __construct( public function __construct(
public int $textId,
public string $title, public string $title,
) {} ) {}
} }

View file

@ -11,6 +11,7 @@ class FakeNodeRepository implements NodeRepository
public function create(CreateNodeDto $dto): Node public function create(CreateNodeDto $dto): Node
{ {
return new Node( return new Node(
text: $dto->text,
title: $dto->title, title: $dto->title,
); );
} }