Skip to content

Commit

Permalink
Make service aliases public
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Jan 19, 2020
1 parent 7d9aea5 commit 5fe5e13
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/DependencyInjection/NucleosUserExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@

namespace Nucleos\UserBundle\DependencyInjection;

use Nucleos\UserBundle\Mailer\MailerInterface;
use Nucleos\UserBundle\Model\GroupManagerInterface;
use Nucleos\UserBundle\Model\UserManagerInterface;
use Nucleos\UserBundle\Util\TokenGeneratorInterface;
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\Alias;
Expand Down Expand Up @@ -86,10 +89,14 @@ public function load(array $configs, ContainerBuilder $container): void
$loader->load('flash_notifications.xml');
}

$container->setAlias('nucleos_user.util.email_canonicalizer', $config['service']['email_canonicalizer']);
$container->setAlias('nucleos_user.util.username_canonicalizer', $config['service']['username_canonicalizer']);
$container->setAlias('nucleos_user.util.token_generator', $config['service']['token_generator']);
$container->setAlias('nucleos_user.util.email_canonicalizer', new Alias($config['service']['email_canonicalizer'], true));
$container->setAlias('nucleos_user.util.username_canonicalizer', new Alias($config['service']['username_canonicalizer'], true));

$container->setAlias('nucleos_user.util.token_generator', new Alias($config['service']['token_generator'], true));
$container->setAlias(TokenGeneratorInterface::class, new Alias($config['service']['token_generator'], true));

$container->setAlias('nucleos_user.user_manager', new Alias($config['service']['user_manager'], true));
$container->setAlias(UserManagerInterface::class, new Alias($config['service']['user_manager'], true));

if ($config['use_listener'] && isset(self::$doctrineDrivers[$config['db_driver']])) {
$listenerDefinition = $container->getDefinition('nucleos_user.user_listener');
Expand All @@ -116,7 +123,8 @@ public function load(array $configs, ContainerBuilder $container): void
}

if ($this->mailerNeeded) {
$container->setAlias('nucleos_user.mailer', $config['service']['mailer']);
$container->setAlias('nucleos_user.mailer', new Alias($config['service']['mailer'], true));
$container->setAlias(MailerInterface::class, new Alias($config['service']['mailer'], true));
}

if ($this->sessionNeeded) {
Expand Down Expand Up @@ -217,7 +225,7 @@ private function loadGroups(array $config, ContainerBuilder $container, XmlFileL
}

$container->setAlias('nucleos_user.group_manager', new Alias($config['group_manager'], true));
$container->setAlias(GroupManagerInterface::class, new Alias('nucleos_user.group_manager', false));
$container->setAlias(GroupManagerInterface::class, new Alias('nucleos_user.group_manager', true));

$this->remapParametersNamespaces($config, $container, [
'' => [
Expand Down

0 comments on commit 5fe5e13

Please sign in to comment.