-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathVideoCreator.php
More file actions
33 lines (25 loc) · 1.04 KB
/
VideoCreator.php
File metadata and controls
33 lines (25 loc) · 1.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
<?php
declare(strict_types=1);
namespace CodelyTv\Mooc\Videos\Application\Create;
use CodelyTv\Mooc\Shared\Domain\Courses\CourseId;
use CodelyTv\Mooc\Shared\Domain\Videos\VideoUrl;
use CodelyTv\Mooc\Videos\Domain\Video;
use CodelyTv\Mooc\Videos\Domain\VideoId;
use CodelyTv\Mooc\Videos\Domain\VideoRepository;
use CodelyTv\Mooc\Videos\Domain\VideoShare;
use CodelyTv\Mooc\Videos\Domain\VideoTitle;
use CodelyTv\Mooc\Videos\Domain\VideoType;
use CodelyTv\Shared\Domain\Bus\Event\EventBus;
final class VideoCreator
{
public function __construct(private VideoRepository $repository, private VideoShare $videoShare, private EventBus $bus)
{
}
public function create(VideoId $id, VideoType $type, VideoTitle $title, VideoUrl $url, CourseId $courseId): void
{
$video = Video::create($id, $type, $title, $url, $courseId);
$this->repository->save($video);
$this->videoShare->post('New video '.$video->title()->value(). ' has been published. Check it out!');
$this->bus->publish(...$video->pullDomainEvents());
}
}