@@ -94,8 +94,8 @@ duplicated service definitions:
94
94
95
95
use AppBundle\Repository\DoctrineUserRepository;
96
96
use AppBundle\Repository\DoctrinePostRepository;
97
+ use Symfony\Component\DependencyInjection\ChildDefinition;
97
98
use Symfony\Component\DependencyInjection\Reference;
98
- use Symfony\Component\DependencyInjection\DefinitionDecorator;
99
99
100
100
// as no class is configured, the parent service MUST be abstract
101
101
$container->register('app.base_doctrine_repository')
@@ -104,12 +104,13 @@ duplicated service definitions:
104
104
;
105
105
106
106
// extend the app.base_doctrine_repository service
107
- $definition = new DefinitionDecorator ('app.base_doctrine_repository');
107
+ $definition = new ChildDefinition ('app.base_doctrine_repository');
108
108
$definition->setClass(DoctrineUserRepository::class);
109
109
$container->setDefinition('app.user_repository', $definition);
110
110
111
- $definition = new DefinitionDecorator ('app.base_doctrine_repository');
111
+ $definition = new ChildDefinition ('app.base_doctrine_repository');
112
112
$definition->setClass(DoctrinePostRepository::class);
113
+
113
114
$container->setDefinition('app.post_repository', $definition);
114
115
115
116
// ...
@@ -201,19 +202,19 @@ in the child class:
201
202
202
203
use AppBundle\Repository\DoctrineUserRepository;
203
204
use AppBundle\Repository\DoctrinePostRepository;
205
+ use Symfony\Component\DependencyInjection\ChildDefinition;
204
206
use Symfony\Component\DependencyInjection\Reference;
205
- use Symfony\Component\DependencyInjection\DefinitionDecorator;
206
207
// ...
207
208
208
- $definition = new DefinitionDecorator ('app.base_doctrine_repository');
209
+ $definition = new ChildDefinition ('app.base_doctrine_repository');
209
210
$definition->setClass(DoctrineUserRepository::class);
210
211
// overrides the public setting of the parent service
211
212
$definition->setPublic(false);
212
213
// appends the '@app.username_checker' argument to the parent argument list
213
214
$definition->addArgument(new Reference('app.username_checker'));
214
215
$container->setDefinition('app.user_repository', $definition);
215
216
216
- $definition = new DefinitionDecorator ('app.base_doctrine_repository');
217
+ $definition = new ChildDefinition ('app.base_doctrine_repository');
217
218
$definition->setClass(DoctrinePostRepository::class);
218
219
// overrides the first argument
219
220
$definition->replaceArgument(0, new Reference('doctrine.custom_entity_manager'));
0 commit comments