8000 replace DefinitionDecorator with ChildDefinition by xabbuh · Pull Request #7253 · symfony/symfony-docs · GitHub
[go: up one dir, main page]

Skip to content

replace DefinitionDecorator with ChildDefinition #7253

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 25, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions security/custo 8000 m_authentication_provider.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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);
}
Expand Down Expand Up @@ -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']);
// ...
Expand Down
13 changes: 7 additions & 6 deletions service_container/parent_services.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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);

// ...
Expand Down Expand Up @@ -201,19 +202,19 @@ 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);
// appends the '@app.username_checker' argument to the parent argument list
$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'));
Expand Down
0