Skip to content

Instantly share code, notes, and snippets.

@morontt
Created December 26, 2014 09:24
Show Gist options
  • Select an option

  • Save morontt/1f6b98af5b92e5e73256 to your computer and use it in GitHub Desktop.

Select an option

Save morontt/1f6b98af5b92e5e73256 to your computer and use it in GitHub Desktop.
tags fixtures
<?php
namespace XtrCommunity\QuBundle\DataFixtures\ORM;
use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Common\Persistence\ObjectManager;
use XtrCommunity\QuBundle\Entity\Tag;
class LoadTagData extends AbstractFixture implements OrderedFixtureInterface
{
/**
* {@inheritDoc}
*/
public function load(ObjectManager $manager)
{
$tagOne = new Tag();
$tagOne->setName('sleep');
$manager->persist($tagOne);
$tagTwo = new Tag();
$tagTwo->setName('Mac');
$manager->persist($tagTwo);
$tagThree = new Tag();
$tagThree->setName('security');
$manager->persist($tagThree);
$tagFour = new Tag();
$tagFour->setName('Thunderbolt');
$manager->persist($tagFour);
$tagFive = new Tag();
$tagFive->setName('Drive Icons');
$manager->persist($tagFive);
$manager->flush();
$this->addReference('tag-one', $tagOne);
$this->addReference('tag-two', $tagTwo);
$this->addReference('tag-three', $tagThree);
$this->addReference('tag-four', $tagFour);
$this->addReference('tag-five', $tagFive);
}
public function getOrder()
{
return 2;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment