add text to node
This commit is contained in:
parent
e55133ceac
commit
c0994d806e
5 changed files with 17 additions and 0 deletions
|
|
@ -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,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
) {}
|
) {}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue