diff options
author | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-02-24 07:42:09 +0100 |
---|---|---|
committer | Nicolas LÅ“uillet <nicolas@loeuillet.org> | 2015-03-06 20:50:31 +0100 |
commit | 46bbd8d321e6a00131f0e6ed96fa6f3d693b3678 (patch) | |
tree | 331d511837716ec7a7956c35f51dc3a14a1ca11c /src/Wallabag/CoreBundle/DataFixtures | |
parent | 6c87418ff013cfd03093c3f01e20518e580d80bb (diff) | |
download | wallabag-46bbd8d321e6a00131f0e6ed96fa6f3d693b3678.tar.gz wallabag-46bbd8d321e6a00131f0e6ed96fa6f3d693b3678.tar.zst wallabag-46bbd8d321e6a00131f0e6ed96fa6f3d693b3678.zip |
relation between tags and entries
Diffstat (limited to 'src/Wallabag/CoreBundle/DataFixtures')
-rw-r--r-- | src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php | 9 | ||||
-rw-r--r-- | src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php | 61 |
2 files changed, 9 insertions, 61 deletions
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php index 3be323ed..edab9adc 100644 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php +++ b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadEntryData.php | |||
@@ -6,6 +6,7 @@ use Doctrine\Common\DataFixtures\AbstractFixture; | |||
6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; | 6 | use Doctrine\Common\DataFixtures\OrderedFixtureInterface; |
7 | use Doctrine\Common\Persistence\ObjectManager; | 7 | use Doctrine\Common\Persistence\ObjectManager; |
8 | use Wallabag\CoreBundle\Entity\Entry; | 8 | use Wallabag\CoreBundle\Entity\Entry; |
9 | use Wallabag\CoreBundle\Entity\Tag; | ||
9 | 10 | ||
10 | class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | 11 | class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface |
11 | { | 12 | { |
@@ -37,6 +38,14 @@ class LoadEntryData extends AbstractFixture implements OrderedFixtureInterface | |||
37 | $entry3->setTitle('test title entry3'); | 38 | $entry3->setTitle('test title entry3'); |
38 | $entry3->setContent('This is my content /o/'); | 39 | $entry3->setContent('This is my content /o/'); |
39 | 40 | ||
41 | $tag1 = new Tag(); | ||
42 | $tag1->setLabel("foo"); | ||
43 | $tag2 = new Tag(); | ||
44 | $tag2->setLabel("bar"); | ||
45 | |||
46 | $entry3->addTag($tag1); | ||
47 | $entry3->addTag($tag2); | ||
48 | |||
40 | $manager->persist($entry3); | 49 | $manager->persist($entry3); |
41 | 50 | ||
42 | $this->addReference('entry3', $entry3); | 51 | $this->addReference('entry3', $entry3); |
diff --git a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php b/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php deleted file mode 100644 index 4d9846b6..00000000 --- a/src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php +++ /dev/null | |||
@@ -1,61 +0,0 @@ | |||
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 | } | ||