[DoctrineBundle, DoctrineAbstractBundle, DoctrineMongoDBBundle] added container aware fixture loader
Updated load data fixtures command in DoctrineMongoDBBundle to be identical to the one in DoctrineBundle Created custom loader, that passes $container to all ContainerAware DataFixtures
This commit is contained in:
parent
734be8107c
commit
d447d22809
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace Symfony\Bundle\DoctrineAbstractBundle\Common\DataFixtures;
|
||||
|
||||
use Doctrine\Common\DataFixtures\FixtureInterface;
|
||||
use Doctrine\Common\DataFixtures\Loader as BaseLoader;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
class Loader extends BaseLoader
|
||||
{
|
||||
private $container;
|
||||
|
||||
public function __construct(ContainerInterface $container)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
|
||||
public function addFixture(FixtureInterface $fixture)
|
||||
{
|
||||
if ($fixture instanceof ContainerAwareInterface) {
|
||||
$fixture->setContainer($container);
|
||||
}
|
||||
|
||||
parent::addFixture($fixture);
|
||||
}
|
||||
}
|
@ -72,7 +72,7 @@ EOT
|
||||
}
|
||||
}
|
||||
|
||||
$loader = new \Doctrine\Common\DataFixtures\Loader();
|
||||
$loader = $loader = new \Symfony\Bundle\DoctrineAbstractBundle\Common\DataFixtures\Loader($this->container);
|
||||
foreach ($paths as $path) {
|
||||
if (is_dir($path)) {
|
||||
$loader->loadFromDirectory($path);
|
||||
|
@ -72,11 +72,11 @@ EOT
|
||||
}
|
||||
}
|
||||
|
||||
$paths = array_filter($paths, 'is_dir');
|
||||
|
||||
$loader = new \Doctrine\Common\DataFixtures\Loader();
|
||||
$loader = new \Symfony\Bundle\DoctrineAbstractBundle\Common\DataFixtures\Loader($this->container);
|
||||
foreach ($paths as $path) {
|
||||
$loader->loadFromDirectory($path);
|
||||
if (is_dir($path)) {
|
||||
$loader->loadFromDirectory($path);
|
||||
}
|
||||
}
|
||||
$fixtures = $loader->getFixtures();
|
||||
$purger = new \Doctrine\Common\DataFixtures\Purger\MongoDBPurger($dm);
|
||||
|
Reference in New Issue
Block a user