-
Notifications
You must be signed in to change notification settings - Fork 232
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #529 from arendjantetteroo/fixture-autowire
First implementation of symfony fixture loader + group support #461
- Loading branch information
Showing
19 changed files
with
875 additions
and
37 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Doctrine Fixtures Bundle | ||
* | ||
* The code was originally distributed inside the Symfony framework. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* (c) Doctrine Project | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Doctrine\Bundle\MongoDBBundle\DependencyInjection\Compiler; | ||
|
||
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\DependencyInjection\Reference; | ||
|
||
final class FixturesCompilerPass implements CompilerPassInterface | ||
{ | ||
const FIXTURE_TAG = 'doctrine.fixture.odm.mongodb'; | ||
|
||
public function process(ContainerBuilder $container) | ||
{ | ||
$definition = $container->getDefinition('doctrine_mongodb.odm.symfony.fixtures.loader'); | ||
$taggedServices = $container->findTaggedServiceIds(self::FIXTURE_TAG); | ||
|
||
$fixtures = []; | ||
foreach ($taggedServices as $serviceId => $tags) { | ||
$groups = []; | ||
foreach ($tags as $tagData) { | ||
if (! isset($tagData['group'])) { | ||
continue; | ||
} | ||
|
||
$groups[] = $tagData['group']; | ||
} | ||
|
||
$fixtures[] = [ | ||
'fixture' => new Reference($serviceId), | ||
'groups' => $groups, | ||
]; | ||
} | ||
|
||
$definition->addMethodCall('addFixtures', [$fixtures]); | ||
} | ||
} |
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\MongoDBBundle\Fixture; | ||
|
||
use Doctrine\Common\DataFixtures\AbstractFixture; | ||
|
||
/** | ||
* Base class designed for data fixtures so they don't have to extend and | ||
* implement different classes/interfaces according to their needs. | ||
*/ | ||
abstract class Fixture extends AbstractFixture implements ODMFixtureInterface | ||
{ | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\MongoDBBundle\Fixture; | ||
|
||
/** | ||
* FixtureGroupInterface can be implemented by fixtures that belong in groups | ||
*/ | ||
interface FixtureGroupInterface | ||
{ | ||
/** | ||
* This method must return an array of groups | ||
* on which the implementing class belongs to | ||
* | ||
* @return string[] | ||
*/ | ||
public static function getGroups(); | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<?php | ||
|
||
namespace Doctrine\Bundle\MongoDBBundle\Fixture; | ||
|
||
use Doctrine\Common\DataFixtures\FixtureInterface; | ||
|
||
/** | ||
* Marks your fixtures that are specifically for the ODM. | ||
*/ | ||
interface ODMFixtureInterface extends FixtureInterface | ||
{ | ||
} |
Oops, something went wrong.