|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace App\Users\DataFixtures; |
|
4
|
|
|
|
|
5
|
|
|
use App\Countries\DataFixtures\CountriesFixtures; |
|
6
|
|
|
use App\Countries\Entity\Country; |
|
7
|
|
|
use App\Movies\DataFixtures\MoviesFixtures; |
|
8
|
|
|
use App\Movies\Entity\Movie; |
|
9
|
|
|
use App\Movies\Entity\MovieReleaseDate; |
|
10
|
|
|
use App\Users\Entity\User; |
|
11
|
|
|
use App\Users\Entity\UserInterestedMovie; |
|
12
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture; |
|
13
|
|
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface; |
|
14
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
|
15
|
|
|
|
|
16
|
|
|
class UsersMoviesFixtures extends Fixture implements DependentFixtureInterface |
|
17
|
|
|
{ |
|
18
|
|
|
const RELEASE_DATE = '2018-01-01'; |
|
19
|
|
|
const MOVIE_ID = MoviesFixtures::MOVIE_1_ID; |
|
20
|
|
|
|
|
21
|
|
|
/** |
|
22
|
|
|
* @param ObjectManager $manager |
|
23
|
|
|
* |
|
24
|
|
|
* @throws |
|
25
|
|
|
*/ |
|
26
|
|
|
public function load(ObjectManager $manager): void |
|
27
|
|
|
{ |
|
28
|
|
|
$movie = $manager->find(Movie::class, self::MOVIE_ID); |
|
29
|
|
|
$ukr = $manager->find(Country::class, CountriesFixtures::COUNTRY_UKR_ID); |
|
30
|
|
|
$user = $manager->find(User::class, UsersFixtures::MOVIE_TESTER_ID); |
|
31
|
|
|
$date = new \DateTime(self::RELEASE_DATE); |
|
32
|
|
|
$releaseDate = new MovieReleaseDate($movie, $ukr, $date); |
|
|
|
|
|
|
33
|
|
|
|
|
34
|
|
|
$userInterestedMovie = new UserInterestedMovie($user, $movie); |
|
|
|
|
|
|
35
|
|
|
|
|
36
|
|
|
$manager->persist($releaseDate); |
|
37
|
|
|
$manager->persist($userInterestedMovie); |
|
38
|
|
|
$manager->flush(); |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
public function getDependencies() |
|
42
|
|
|
{ |
|
43
|
|
|
return [UsersFixtures::class, MoviesFixtures::class, CountriesFixtures::class]; |
|
44
|
|
|
} |
|
45
|
|
|
} |
|
46
|
|
|
|
It seems like the type of the argument is not accepted by the function/method which you are calling.
In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.
We suggest to add an explicit type cast like in the following example: