Skip to content

Commit

Permalink
Merge pull request #4 from kuldippujara/master
Browse files Browse the repository at this point in the history
added use fixture loader option
  • Loading branch information
yceruto authored Mar 3, 2022
2 parents cdf64b5 + b0fe239 commit 4447796
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/VIPSoft/DoctrineDataFixturesExtension/Extension.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@ public function configure(ArrayNodeDefinition $builder)
->arrayNode('fixtures')
->prototype('scalar')->end()
->end()
->booleanNode('use_fixture_loader')
->defaultValue(false)
->end()
->scalarNode('lifetime')
->defaultValue('feature')
->validate()
Expand Down Expand Up @@ -90,6 +93,7 @@ public function load(ContainerBuilder $container, array $config)
$container->setParameter('behat.doctrine_data_fixtures.lifetime', $config['lifetime']);
$container->setParameter('behat.doctrine_data_fixtures.migrations', $config['migrations']);
$container->setParameter('behat.doctrine_data_fixtures.use_backup', $config['use_backup']);
$container->setParameter('behat.doctrine_data_fixtures.use_fixture_loader', $config['use_fixture_loader']);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public function __construct(ContainerInterface $container, Kernel $kernel)
$this->directories = $container->getParameter('behat.doctrine_data_fixtures.directories');
$this->migrations = $container->getParameter('behat.doctrine_data_fixtures.migrations');
$this->useBackup = $container->getParameter('behat.doctrine_data_fixtures.use_backup');
$this->useFixtureLoader = $container->getParameter('behat.doctrine_data_fixtures.use_fixture_loader');
$this->kernel = $kernel;

if ($this->useBackup) {
Expand Down Expand Up @@ -100,8 +101,13 @@ private function init()
*/
private function getFixtureLoader()
{

$container = $this->kernel->getContainer();

if ($this->useFixtureLoader && $container->get('test.service_container')->has('doctrine.fixtures.loader')) {
return $container->get('test.service_container')->get('doctrine.fixtures.loader');
}

$loader = class_exists(FixtureLoader::class)
? new FixtureLoader($container)
: (class_exists('Symfony\Bridge\Doctrine\DataFixtures\ContainerAwareLoader')
Expand Down

0 comments on commit 4447796

Please sign in to comment.