Created
October 16, 2010 18:50
-
-
Save immutef/630152 to your computer and use it in GitHub Desktop.
Latest Symfony2 Fixtures for Doctrine2
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // src/Application/GameBundle/DataFixtures/ORM/LoadGameData.php | |
// cd src/vendor && git clone git://github.com/doctrine/data-fixtures doctrine-data-fixtures | |
// register the "Doctrine\Common\DataFixtures" namespace in your src/autoload.php file | |
namespace Application\GameBundle\DataFixtures\ORM; | |
use Doctrine\ORM\EntityManager, | |
Doctrine\Common\DataFixtures\FixtureInterface; | |
use Application\GameBundle\Entity\Game; | |
class LoadGameData implements FixtureInterface | |
{ | |
public function load($manager) | |
{ | |
// first fixture ... | |
$game1 = new Game(); | |
$game1->setFoo('bar'); | |
$manager->persist($game1); | |
// add more fixtures ... | |
$manager->flush(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment