Skip to content

Instantly share code, notes, and snippets.

@Etheriq
Created October 21, 2015 10:55
Show Gist options
  • Save Etheriq/415e438295a4ae99d401 to your computer and use it in GitHub Desktop.
Save Etheriq/415e438295a4ae99d401 to your computer and use it in GitHub Desktop.
Example fixtures loader class
<?php
namespace AppBundle\DataFixtures\ORM;
use Hautelook\AliceBundle\Alice\DataFixtureLoader;
class FixturesLoader extends DataFixtureLoader
{
/**
* Returns an array of file paths to fixtures
*
* @return array<string>
*/
protected function getFixtures()
{
$env = $this->container->get('kernel')->getEnvironment();
if ($env == 'test') {
return [
__DIR__ . '/DataForTests/tag.yml',
__DIR__ . '/DataForTests/categories.yml',
__DIR__ . '/DataForTests/user.yml',
];
}
return [
__DIR__ . '/Data/tag.yml',
__DIR__ . '/Data/categories.yml',
__DIR__ . '/Data/user.yml',
];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment