|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Movies\DataFixtures; |
|
4
|
|
|
|
|
5
|
|
|
use App\Genres\Entity\Genre; |
|
6
|
|
|
use App\Genres\Entity\GenreTranslations; |
|
7
|
|
|
use App\Movies\DTO\MovieDTO; |
|
8
|
|
|
use App\Movies\DTO\MovieTranslationDTO; |
|
9
|
|
|
use App\Movies\Entity\Movie; |
|
10
|
|
|
use App\Movies\Entity\MovieTMDB; |
|
11
|
|
|
use App\Movies\Entity\MovieTranslations; |
|
12
|
|
|
use App\Movies\Service\MovieManageService; |
|
13
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture; |
|
14
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
15
|
|
|
|
|
16
|
|
|
class MoviesFixtures extends Fixture |
|
17
|
|
|
{ |
|
18
|
|
|
const MOVIE_TITLE = 'zMs1Os7qwEqWxXvb'; |
|
19
|
|
|
|
|
20
|
|
|
private $movieManageService; |
|
21
|
|
|
|
|
22
|
|
|
public function __construct(MovieManageService $movieManageService) |
|
23
|
|
|
{ |
|
24
|
|
|
$this->movieManageService = $movieManageService; |
|
25
|
|
|
} |
|
26
|
|
|
|
|
27
|
|
|
/** |
|
28
|
|
|
* @param ObjectManager $manager |
|
29
|
|
|
* @throws \Exception |
|
30
|
|
|
*/ |
|
31
|
|
|
public function load(ObjectManager $manager): void |
|
32
|
|
|
{ |
|
33
|
|
|
$movieTitle = self::MOVIE_TITLE; |
|
34
|
|
|
$movieDTO = new MovieDTO($movieTitle, 'http://placehold.it/320x480', 'imdb-test-id', 60000, 100, '-10 years'); |
|
35
|
|
|
$tmdb = new MovieTMDB(1, 7.8, 100); |
|
36
|
|
|
|
|
37
|
|
|
$testGenre = new Genre(); |
|
38
|
|
|
$testGenre |
|
39
|
|
|
->addTranslation(new GenreTranslations($testGenre, 'en', 'Test Genre (en)')) |
|
40
|
|
|
->addTranslation(new GenreTranslations($testGenre, 'uk', 'Test Genre (uk)')) |
|
41
|
|
|
->addTranslation(new GenreTranslations($testGenre, 'ru', 'Test Genre (ru)')); |
|
42
|
|
|
|
|
43
|
|
|
$movie = $this->movieManageService->createMovieByDTO($movieDTO, $tmdb, [$testGenre], [ |
|
44
|
|
|
new MovieTranslationDTO('en', "$movieTitle (en)", 'http://placehold.it/480x320', 'Overview (en)'), |
|
45
|
|
|
new MovieTranslationDTO('uk', "$movieTitle (uk)", 'http://placehold.it/480x320', 'Overview (uk)'), |
|
46
|
|
|
new MovieTranslationDTO('ru', "$movieTitle (ru)", 'http://placehold.it/480x320', 'Overview (ru)'), |
|
47
|
|
|
]); |
|
48
|
|
|
|
|
49
|
|
|
$manager->persist($movie); |
|
50
|
|
|
$manager->flush(); |
|
51
|
|
|
} |
|
52
|
|
|
} |