Skip to content

Commit

Permalink
bug #32379 [SecurityBundle] conditionally register services (xabbuh)
Browse files Browse the repository at this point in the history
This PR was merged into the 3.4 branch.

Discussion
----------

[SecurityBundle] conditionally register services

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #32342
| License       | MIT
| Doc PR        |

Commits
-------

8fbcdf2 conditionally register services
  • Loading branch information
Robin Chalas committed Jul 5, 2019
2 parents d9833ac + 8fbcdf2 commit 7f43681
Showing 1 changed file with 14 additions and 4 deletions.
Expand Up @@ -28,6 +28,8 @@
use Symfony\Component\Security\Core\Authorization\ExpressionLanguage;
use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
use Symfony\Component\Security\Core\Encoder\Argon2iPasswordEncoder;
use Symfony\Component\Templating\Helper\Helper;
use Twig\Extension\AbstractExtension;

/**
* SecurityExtension.
Expand Down Expand Up @@ -69,8 +71,18 @@ public function load(array $configs, ContainerBuilder $container)
$loader->load('security.xml');
$loader->load('security_listeners.xml');
$loader->load('security_rememberme.xml');
$loader->load('templating_php.xml');
$loader->load('templating_twig.xml');

if (class_exists(Helper::class)) {
$loader->load('templating_php.xml');

$container->getDefinition('templating.helper.logout_url')->setPrivate(true);
$container->getDefinition('templating.helper.security')->setPrivate(true);
}

if (class_exists(AbstractExtension::class)) {
$loader->load('templating_twig.xml');
}

$loader->load('collectors.xml');
$loader->load('guard.xml');

Expand All @@ -79,8 +91,6 @@ public function load(array $configs, ContainerBuilder $container)
$container->getDefinition('security.firewall.context')->setPrivate(true);
$container->getDefinition('security.validator.user_password')->setPrivate(true);
$container->getDefinition('security.rememberme.response_listener')->setPrivate(true);
$container->getDefinition('templating.helper.logout_url')->setPrivate(true);
$container->getDefinition('templating.helper.security')->setPrivate(true);
$container->getAlias('security.encoder_factory')->setPrivate(true);

if ($container->hasParameter('kernel.debug') && $container->getParameter('kernel.debug')) {
Expand Down

0 comments on commit 7f43681

Please sign in to comment.