1
|
|
|
<?php |
2
|
|
|
namespace Developtech\AgilityBundle\DataFixtures\ORM; |
3
|
|
|
|
4
|
|
|
use Doctrine\Common\Persistence\ObjectManager; |
5
|
|
|
use Doctrine\Common\DataFixtures\AbstractFixture; |
6
|
|
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; |
7
|
|
|
use Symfony\Component\DependencyInjection\ContainerInterface; |
8
|
|
|
use Symfony\Component\DependencyInjection\ContainerAwareInterface; |
9
|
|
|
|
10
|
|
|
use Developtech\AgilityBundle\Entity\Project; |
11
|
|
|
|
12
|
|
|
class LoadProjectData extends AbstractFixture implements OrderedFixtureInterface, ContainerAwareInterface { |
13
|
|
|
/** @var ContainerInterface */ |
14
|
|
|
private $container; |
15
|
|
|
/** |
16
|
|
|
* @param ContainerInterface $container |
17
|
|
|
*/ |
18
|
1 |
|
public function setContainer(ContainerInterface $container = null) { |
19
|
1 |
|
$this->container = $container; |
20
|
1 |
|
} |
21
|
|
|
/** |
22
|
|
|
* @param ObjectManager $manager |
23
|
|
|
*/ |
24
|
1 |
|
public function load(ObjectManager $manager) { |
25
|
1 |
|
$data = include('fixtures/projects.php'); |
26
|
1 |
|
foreach ($data as $projectData) |
27
|
|
|
{ |
28
|
|
|
$project = |
29
|
1 |
|
(new Project()) |
30
|
1 |
|
->setId($projectData['id']) |
31
|
1 |
|
->setName($projectData['name']) |
32
|
1 |
|
->setSlug($projectData['slug']) |
33
|
1 |
|
->setDescription($projectData['description']) |
34
|
1 |
|
->setBetaTestStatus($projectData['beta_test_status']) |
35
|
1 |
|
->setNbBetaTesters($projectData['nb_beta_testers']) |
36
|
1 |
|
->setCreatedAt(new \DateTime($projectData['created_at'])) |
37
|
1 |
|
; |
38
|
1 |
|
$manager->persist($project); |
39
|
1 |
|
$this->addReference("project-{$project->getId()}", $project); |
40
|
1 |
|
} |
41
|
1 |
|
$manager->flush(); |
42
|
1 |
|
$manager->clear(Project::class); |
43
|
1 |
|
} |
44
|
|
|
/** |
45
|
|
|
* @return int |
46
|
|
|
*/ |
47
|
1 |
|
public function getOrder() { |
48
|
1 |
|
return 1; |
49
|
|
|
} |
50
|
|
|
} |
51
|
|
|
|