Skip to content

Commit f892536

Browse files
author
Robin Chalas
committed
fix merge
1 parent 5b6c1b3 commit f892536

File tree

1 file changed

+9
-15
lines changed

1 file changed

+9
-15
lines changed

src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,6 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
252252
$defaultProvider = $providerIds[$normalizedName];
253253
} elseif (1 === count($providerIds)) {
254254
$defaultProvider = reset($providerIds);
255-
} elseif ($providerIds) {
256-
throw new InvalidConfigurationException(sprintf('Not configuring explicitly the provider on "%s" firewall is ambiguous as there is more than one registered provider.', $id));
257255
}
258256

259257
$config->replaceArgument(5, $defaultProvider);
@@ -412,8 +410,10 @@ private function createAuthenticationListeners($container, $id, $firewall, &$aut
412410
throw new InvalidConfigurationException(sprintf('Invalid firewall "%s": user provider "%s" not found.', $id, $firewall[$key]['provider']));
413411
}
414412
$userProvider = $providerIds[$normalizedName];
413+
} elseif($defaultProvider) {
414+
$userProvider = $defaultProvider;
415415
} else {
416-
$userProvider = $defaultProvider ?: $this->getFirstProvider($id, $key, $providerIds);
416+
throw new InvalidConfigurationException(sprintf('Not configuring explicitly the provider for the "%s" listener on "%s" firewall is ambiguous as there is more than one registered provider.', $key, $id));
417417
}
418418

419419
list($provider, $listenerId, $defaultEntryPoint) = $factory->create($container, $id, $firewall[$key], $userProvider, $defaultEntryPoint);
@@ -594,9 +594,13 @@ private function createExceptionListener($container, $config, $id, $defaultEntry
594594
return $exceptionListenerId;
595595
}
596596

597-
private function createSwitchUserListener($container, $id, $config, $defaultProvider, $stateless)
597+
private function createSwitchUserListener($container, $id, $config, $defaultProvider = null, $stateless)
598598
{
599-
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : ($defaultProvider ?: $this->getFirstProvider($id, 'switch_user', $providerIds));
599+
$userProvider = isset($config['provider']) ? $this->getUserProviderId($config['provider']) : $defaultProvider;
600+
601+
if (!$userProvider) {
602+
throw new InvalidConfigurationException(sprintf('Not configuring explicitly the provider for the "switch_user" listener on "%s" firewall is ambiguous as there is more than one registered provider.', $id));
603+
}
600604

601605
$switchUserListenerId = 'security.authentication.switchuser_listener.'.$id;
602606
$listener = $container->setDefinition($switchUserListenerId, new ChildDefinition('security.authentication.switchuser_listener'));
@@ -695,14 +699,4 @@ private function getExpressionLanguage()
695699

696700
return $this->expressionLanguage;
697701
}
698-
699-
/**
700-
* @deprecated since version 3.4, to be removed in 4.0
701-
*/
702-
private function getFirstProvider($firewallName, $listenerName, array $providerIds)
703-
{
704-
@trigger_error(sprintf('Listener "%s" on firewall "%s" has no "provider" set but multiple providers exist. Using the first configured provider (%s) is deprecated since 3.4 and will throw an exception in 4.0, set the "provider" key on the firewall instead.', $listenerName, $firewallName, $first = array_keys($providerIds)[0]), E_USER_DEPRECATED);
705-
706-
return $providerIds[$first];
707-
}
708702
}

0 commit comments

Comments
 (0)