From ab097ca7b8aaf558be3d0de47e339a7f3c8d84b2 Mon Sep 17 00:00:00 2001 From: Christian Flothmann Date: Tue, 13 Dec 2016 20:22:53 +0100 Subject: [PATCH] replace DefinitionDecorator with ChildDefinition --- security/custom_authentication_provider.rst | 8 ++++---- service_container/parent_services.rst | 13 +++++++------ 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/security/custom_authentication_provider.rst b/security/custom_authentication_provider.rst index 27b0c9f2194..233d2a7daef 100644 --- a/security/custom_authentication_provider.rst +++ b/security/custom_authentication_provider.rst @@ -315,9 +315,9 @@ create a class which implements // src/AppBundle/DependencyInjection/Security/Factory/WsseFactory.php namespace AppBundle\DependencyInjection\Security\Factory; + use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Reference; - use Symfony\Component\DependencyInjection\DefinitionDecorator; use Symfony\Component\Config\Definition\Builder\NodeDefinition; use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface; @@ -327,12 +327,12 @@ create a class which implements { $providerId = 'security.authentication.provider.wsse.'.$id; $container - ->setDefinition($providerId, new DefinitionDecorator('wsse.security.authentication.provider')) + ->setDefinition($providerId, new ChildDefinition('wsse.security.authentication.provider')) ->replaceArgument(0, new Reference($userProvider)) ; $listenerId = 'security.authentication.listener.wsse.'.$id; - $listener = $container->setDefinition($listenerId, new DefinitionDecorator('wsse.security.authentication.listener')); + $listener = $container->setDefinition($listenerId, new ChildDefinition('wsse.security.authentication.listener')); return array($providerId, $listenerId, $defaultEntryPoint); } @@ -594,7 +594,7 @@ in order to put it to use. $providerId = 'security.authentication.provider.wsse.'.$id; $container ->setDefinition($providerId, - new DefinitionDecorator('wsse.security.authentication.provider')) + new ChildDefinition('wsse.security.authentication.provider')) ->replaceArgument(0, new Reference($userProvider)) ->replaceArgument(2, $config['lifetime']); // ... diff --git a/service_container/parent_services.rst b/service_container/parent_services.rst index 528b3bb8c29..1ed8b49ef5c 100644 --- a/service_container/parent_services.rst +++ b/service_container/parent_services.rst @@ -94,8 +94,8 @@ duplicated service definitions: use AppBundle\Repository\DoctrineUserRepository; use AppBundle\Repository\DoctrinePostRepository; + use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Reference; - use Symfony\Component\DependencyInjection\DefinitionDecorator; // as no class is configured, the parent service MUST be abstract $container->register('app.base_doctrine_repository') @@ -104,12 +104,13 @@ duplicated service definitions: ; // extend the app.base_doctrine_repository service - $definition = new DefinitionDecorator('app.base_doctrine_repository'); + $definition = new ChildDefinition('app.base_doctrine_repository'); $definition->setClass(DoctrineUserRepository::class); $container->setDefinition('app.user_repository', $definition); - $definition = new DefinitionDecorator('app.base_doctrine_repository'); + $definition = new ChildDefinition('app.base_doctrine_repository'); $definition->setClass(DoctrinePostRepository::class); + $container->setDefinition('app.post_repository', $definition); // ... @@ -201,11 +202,11 @@ in the child class: use AppBundle\Repository\DoctrineUserRepository; use AppBundle\Repository\DoctrinePostRepository; + use Symfony\Component\DependencyInjection\ChildDefinition; use Symfony\Component\DependencyInjection\Reference; - use Symfony\Component\DependencyInjection\DefinitionDecorator; // ... - $definition = new DefinitionDecorator('app.base_doctrine_repository'); + $definition = new ChildDefinition('app.base_doctrine_repository'); $definition->setClass(DoctrineUserRepository::class); // overrides the public setting of the parent service $definition->setPublic(false); @@ -213,7 +214,7 @@ in the child class: $definition->addArgument(new Reference('app.username_checker')); $container->setDefinition('app.user_repository', $definition); - $definition = new DefinitionDecorator('app.base_doctrine_repository'); + $definition = new ChildDefinition('app.base_doctrine_repository'); $definition->setClass(DoctrinePostRepository::class); // overrides the first argument $definition->replaceArgument(0, new Reference('doctrine.custom_entity_manager'));