Skip to content

Commit

Permalink
Fix Symfony dependencies & Doc regarding the autoconfiguration (#104)
Browse files Browse the repository at this point in the history
  • Loading branch information
theofidry authored Sep 18, 2018
1 parent 8478747 commit 7991382
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 7 deletions.
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -338,7 +338,21 @@ final class UserProcessor implements ProcessorInterface
```

In Symfony, if you wish to register the processor above you need to tag it with the
`fidry_alice_data_fixtures.processor` tag:
`fidry_alice_data_fixtures.processor` tag unless you have `autoconfigure` enabled:

```yaml
# app/config/services.yml

services:
_defaults:
autoconfigure: true

AppBundle\DataFixtures\Processor\UserProcessor:
arguments:
- '@password_hasher'
```
Without `autoconfigure`:

```yaml
# app/config/services.yml
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
"conflict": {
"doctrine/orm": "<2.5",
"illuminate/database": "<5.5",
"ocramius/proxy-manager": "<2.1"
"ocramius/proxy-manager": "<2.1",
"symfony/framework-bundle": "<3.4"
},
"suggest": {
"doctrine/data-fixtures": "To use Doctrine",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,9 @@ public function load(array $configs, ContainerBuilder $container)
$loader = new XmlFileLoader($container, new FileLocator(self::SERVICES_DIR));
$loader->load('loader.xml');

// Register autoconfiguration rules for Symfony DI 3.3+
if (method_exists($container, 'registerForAutoconfiguration')) {
$container->registerForAutoconfiguration(ProcessorInterface::class)
->addTag('fidry_alice_data_fixtures.processor');
}
$container->registerForAutoconfiguration(ProcessorInterface::class)
->addTag('fidry_alice_data_fixtures.processor')
;

$this->registerConfig(Configuration::DOCTRINE_ORM_DRIVER, DoctrineBundle::class, $bundles, $processedConfiguration, $loader);
$this->registerConfig(Configuration::DOCTRINE_MONGODB_ODM_DRIVER, DoctrineMongoDBBundle::class, $bundles, $processedConfiguration, $loader);
Expand Down

0 comments on commit 7991382

Please sign in to comment.