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\Entity\Movie; |
8
|
|
|
use App\Movies\Entity\MovieTMDB; |
9
|
|
|
use App\Movies\Entity\MovieTranslations; |
10
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture; |
11
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
12
|
|
|
|
13
|
|
|
class MoviesFixtures extends Fixture |
14
|
|
|
{ |
15
|
|
|
public function load(ObjectManager $manager): void |
16
|
|
|
{ |
17
|
|
|
$tmdb = new MovieTMDB(1); |
18
|
|
|
$tmdb->setVoteAverage(7.8); |
19
|
|
|
$tmdb->setVoteCount(100); |
20
|
|
|
|
21
|
|
|
$movie = new Movie('Original Title', 'http://placehold.it/320x480', $tmdb); |
22
|
|
|
$movie |
23
|
|
|
->addTranslation(new MovieTranslations($movie, 'en', 'Original Title (en)', 'http://placehold.it/480x320', 'Overview (en)')) |
24
|
|
|
->addTranslation(new MovieTranslations($movie, 'uk', 'Оригінальная назва (uk)', 'http://placehold.it/480x320', 'Overview (uk)')) |
25
|
|
|
->addTranslation(new MovieTranslations($movie, 'ru', 'Оригинальное название (ru)', 'http://placehold.it/480x320', 'Overview (ru)')); |
26
|
|
|
$movie->setReleaseDate(new \DateTimeImmutable('-10 years')); |
27
|
|
|
$movie->setRuntime(100); |
28
|
|
|
$movie->setBudget(60000); |
29
|
|
|
$movie->setImdbId('imdb-test-id'); |
30
|
|
|
|
31
|
|
|
$testGenre = new Genre(); |
32
|
|
|
$testGenre |
33
|
|
|
->addTranslation(new GenreTranslations($testGenre, 'en', 'Test Genre (en)')) |
34
|
|
|
->addTranslation(new GenreTranslations($testGenre, 'uk', 'Test Genre (uk)')) |
35
|
|
|
->addTranslation(new GenreTranslations($testGenre, 'ru', 'Test Genre (ru)')); |
36
|
|
|
|
37
|
|
|
$movie->addGenre($testGenre); |
38
|
|
|
|
39
|
|
|
$manager->persist($movie); |
40
|
|
|
$manager->flush(); |
41
|
|
|
} |
42
|
|
|
} |