]>
Commit | Line | Data |
---|---|---|
1 | <?php | |
2 | ||
3 | namespace Wallabag\CoreBundle\DataFixtures\ORM; | |
4 | ||
5 | use Doctrine\Common\DataFixtures\AbstractFixture; | |
6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | |
7 | use Doctrine\Common\Persistence\ObjectManager; | |
8 | use Wallabag\CoreBundle\Entity\Tag; | |
9 | use Wallabag\CoreBundle\Entity\TagsEntries; | |
10 | ||
11 | class LoadTagData extends AbstractFixture implements OrderedFixtureInterface | |
12 | { | |
13 | /** | |
14 | * {@inheritDoc} | |
15 | */ | |
16 | public function load(ObjectManager $manager) | |
17 | { | |
18 | $tag1 = new Tag(); | |
19 | $tag1->setLabel('foo'); | |
20 | ||
21 | $manager->persist($tag1); | |
22 | ||
23 | $this->addReference('tag1', $tag1); | |
24 | ||
25 | $tagsEntries1 = new TagsEntries(); | |
26 | $tagsEntries1->setEntryId($this->getReference('entry1')); | |
27 | $manager->persist($tagsEntries1); | |
28 | ||
29 | $tag2 = new Tag(); | |
30 | $tag2->setLabel('bar'); | |
31 | ||
32 | $manager->persist($tag2); | |
33 | ||
34 | $this->addReference('tag2', $tag2); | |
35 | ||
36 | $tagsEntries2 = new TagsEntries(); | |
37 | $tagsEntries2->setEntryId($this->getReference('entry2')); | |
38 | $manager->persist($tagsEntries2); | |
39 | ||
40 | $tag3 = new Tag(); | |
41 | $tag3->setLabel('baz'); | |
42 | ||
43 | $manager->persist($tag3); | |
44 | ||
45 | $this->addReference('tag3', $tag3); | |
46 | ||
47 | $tagsEntries3 = new TagsEntries(); | |
48 | $tagsEntries3->setEntryId($this->getReference('entry2')); | |
49 | $manager->persist($tagsEntries3); | |
50 | ||
51 | $manager->flush(); | |
52 | } | |
53 | ||
54 | /** | |
55 | * {@inheritDoc} | |
56 | */ | |
57 | public function getOrder() | |
58 | { | |
59 | return 30; | |
60 | } | |
61 | } |