]> git.immae.eu Git - github/wallabag/wallabag.git/commitdiff
fixtures for tag
authorNicolas Lœuillet <nicolas@loeuillet.org>
Sun, 22 Feb 2015 20:25:24 +0000 (21:25 +0100)
committerNicolas Lœuillet <nicolas@loeuillet.org>
Fri, 6 Mar 2015 19:50:30 +0000 (20:50 +0100)
src/Wallabag/CoreBundle/DataFixtures/ORM/LoadTagData.php
src/Wallabag/CoreBundle/Entity/TagsEntries.php [new file with mode: 0644]

index 6b13c2beec31970d40b35127a2cd164c44408ef2..4d9846b61e14d750d5edb7da9e129722a6e072fa 100644 (file)
@@ -6,6 +6,7 @@ use Doctrine\Common\DataFixtures\AbstractFixture;
 use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
 use Doctrine\Common\Persistence\ObjectManager;
 use Wallabag\CoreBundle\Entity\Tag;
+use Wallabag\CoreBundle\Entity\TagsEntries;
 
 class LoadTagData extends AbstractFixture implements OrderedFixtureInterface
 {
@@ -19,16 +20,34 @@ class LoadTagData extends AbstractFixture implements OrderedFixtureInterface
 
         $manager->persist($tag1);
 
+        $this->addReference('tag1', $tag1);
+
+        $tagsEntries1 = new TagsEntries();
+        $tagsEntries1->setEntryId($this->getReference('entry1'));
+        $manager->persist($tagsEntries1);
+
         $tag2 = new Tag();
         $tag2->setLabel('bar');
 
         $manager->persist($tag2);
 
+        $this->addReference('tag2', $tag2);
+
+        $tagsEntries2 = new TagsEntries();
+        $tagsEntries2->setEntryId($this->getReference('entry2'));
+        $manager->persist($tagsEntries2);
+
         $tag3 = new Tag();
         $tag3->setLabel('baz');
 
         $manager->persist($tag3);
 
+        $this->addReference('tag3', $tag3);
+
+        $tagsEntries3 = new TagsEntries();
+        $tagsEntries3->setEntryId($this->getReference('entry2'));
+        $manager->persist($tagsEntries3);
+
         $manager->flush();
     }
 
diff --git a/src/Wallabag/CoreBundle/Entity/TagsEntries.php b/src/Wallabag/CoreBundle/Entity/TagsEntries.php
new file mode 100644 (file)
index 0000000..589f26f
--- /dev/null
@@ -0,0 +1,81 @@
+<?php
+
+namespace Wallabag\CoreBundle\Entity;
+
+use Doctrine\ORM\Mapping as ORM;
+
+/**
+ * TagsEntries
+ *
+ * @ORM\Table(name="tags_entries")
+ */
+class TagsEntries
+{
+    /**
+     * @var integer
+     *
+     * @ORM\Column(name="id", type="integer")
+     * @ORM\Id
+     * @ORM\GeneratedValue(strategy="AUTO")
+     */
+    private $id;
+
+    /**
+     *
+     * @ORM\ManyToOne(targetEntity="Entry", inversedBy="tags_entries")
+     * @ORM\JoinColumn(name="entry_id", referencedColumnName="id")
+     *
+     */
+    private $entryId;
+
+    /**
+     *
+     * @ORM\ManyToOne(targetEntity="Tag", inversedBy="tags_entries")
+     * @ORM\JoinColumn(name="tag_id", referencedColumnName="id")
+     *
+     */
+    private $tagId;
+
+    /**
+     * Get id
+     *
+     * @return integer
+     */
+    public function getId()
+    {
+        return $this->id;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getEntryId()
+    {
+        return $this->entryId;
+    }
+
+    /**
+     * @param mixed $entryId
+     */
+    public function setEntryId($entryId)
+    {
+        $this->entryId = $entryId;
+    }
+
+    /**
+     * @return mixed
+     */
+    public function getTagId()
+    {
+        return $this->tagId;
+    }
+
+    /**
+     * @param mixed $tagId
+     */
+    public function setTagId($tagId)
+    {
+        $this->tagId = $tagId;
+    }
+
+}