fixtures for tag

This commit is contained in:
Nicolas Lœuillet 2015-02-22 21:25:24 +01:00
parent 1bd12b6229
commit 6c87418ff0
2 changed files with 100 additions and 0 deletions

View 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();
}

View file

@ -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;
}
}