epwt / environment-aware-data-fixtures
Environment Aware Data Fixtures extension for DoctrineFixturesBundle
1.0.1
2015-03-12 16:34 UTC
Requires
- php: >=5.3.2
- doctrine/common: ~2.2
- doctrine/data-fixtures: ~1.0
- doctrine/doctrine-fixtures-bundle: ~2.2
Requires (Dev)
- doctrine/orm: ~2.4
This package is auto-updated.
Last update: 2024-10-19 08:59:00 UTC
README
This extension aims to provide a simple way to manage and execute the loading of data fixtures for the Doctrine ORM or ODM for specific environments in Symfony framework.
Default Symfony environments are supported as so. Not all methods are required to implement.
namespace MyDataFixtures;
use Doctrine\Common\Persistence\ObjectManager;
use EPWT\EnvironmentAwareDataFixtures\Doctrine\Common\DataFixtures\EnvironmentAwareFixture;
class LoadUserData implements FixtureInterface
{
public function loadProduction(ObjectManager $manager)
{
$user = new User();
$user->setUsername('epwt');
$user->setPassword('production');
$manager->persist($user);
$manager->flush();
}
public function loadDev(ObjectManager $manager)
{
$user = new User();
$user->setUsername('epwt');
$user->setPassword('dev');
$manager->persist($user);
$manager->flush();
}
public function loadTest(ObjectManager $manager)
{
$user = new User();
$user->setUsername('epwt');
$user->setPassword('test');
$manager->persist($user);
$manager->flush();
}
}
Custom environments also supported just make a method with prefix load for e.g.
public function loadDemo(ObjectManager $manager);