8000 Merge branch '2.7' into 2.8 · symfony/symfony@15106bf · GitHub
[go: up one dir, main page]

Skip to content

Commit 15106bf

Browse files
Merge branch '2.7' into 2.8
* 2.7: Revert "bug #21791 [SecurityBundle] only pass relevant user provider (xabbuh)" [DependencyInjection] inline conditional statements.
2 parents 4d4dec3 + 9aebfad commit 15106bf

File tree

2 files changed

+22
-17
lines changed

2 files changed

+22
-17
lines changed

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,16 @@ private function createFirewalls($config, ContainerBuilder $container)
216216
$firewalls = $config['firewalls'];
217217
$providerIds = $this->createUserProviders($config, $container);
218218

219+
// make the ContextListener aware of the configured user providers
220+
$definition = $container->getDefinition('security.context_listener');
221+
$arguments = $definition->getArguments();
222+
$userProviders = array();
223+
foreach ($providerIds as $userProviderId) {
224+
$userProviders[] = new Reference($userProviderId);
225+
}
226+
$arguments[1] = $userProviders;
227+
$definition->setArguments($arguments);
228+
219229
// load firewall map
220230
$mapDef = $container->getDefinition('security.firewall.map');
221231
$map = $authenticationProviders = array();
@@ -280,7 +290,7 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
280290
$contextKey = $firewall['context'];
281291
}
282292

283-
$listeners[] = new Reference($this->createContextListener($container, $contextKey, $defaultProvider));
293+
$listeners[] = new Reference($this->createContextListener($container, $contextKey));
284294
}
285295

286296
// Logout listener
@@ -365,15 +375,14 @@ private function createFirewall(ContainerBuilder $container, $id, $firewall, &$a
365375
return array($matcher, $listeners, $exceptionListener);
366376
}
367377

368-
private function createContextListener($container, $contextKey, $providerId)
378+
private function createContextListener($container, $contextKey)
369379
{
370380
if (isset($this->contextListeners[$contextKey])) {
371381
return $this->contextListeners[$contextKey];
372382
}
373383

374384
$listenerId = 'security.context_listener.'.count($this->contextListeners);
375385
$listener = $container->setDefinition($listenerId, new DefinitionDecorator('security.context_listener'));
376-
$listener->replaceArgument(1, array(new Reference($providerId)));
377386
$listener->replaceArgument(2, $contextKey);
378387

379388
return $this->contextListeners[$contextKey] = $listenerId;

src/Symfony/Component/DependencyInjection/Dumper/PhpDumper.php

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,11 +1029,7 @@ private function addMethodMap()
10291029
private function addAliases()
10301030
{
10311031
if (!$aliases = $this->container->getAliases()) {
1032-
if ($this->container->isFrozen()) {
1033-
return "\n \$this->aliases = array();\n";
1034-
} else {
1035-
return '';
1036-
}
1032+
return $this->container->isFrozen() ? "\n \$this->aliases = array();\n" : '';
10371033
}
10381034

10391035
$code = " \$this->aliases = array(\n";
@@ -1402,9 +1398,9 @@ private function dumpValue($value, $interpolate = true)
14021398
$service = $this->dumpValue($value->getFactoryService(false));
14031399

14041400
return sprintf('%s->%s(%s)', 0 === strpos($service, '$') ? sprintf('$this->get(%s)', $service) : $this->getServiceCall($value->getFactoryService(false)), $value->getFactoryMethod(false), implode(', ', $arguments));
1405-
} else {
1406-
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
14071401
}
1402+
1403+
throw new RuntimeException('Cannot dump definitions which have factory method without factory service or factory class.');
14081404
}
14091405

14101406
$class = $value->getClass();
@@ -1442,9 +1438,9 @@ private function dumpValue($value, $interpolate = true)
14421438
}
14431439
} elseif (is_object($value) || is_resource($value)) {
14441440
throw new RuntimeException('Unable to dump a service container if a parameter is an object or a resource.');
1445-
} else {
1446-
return $this->export($value);
14471441
}
1442+
1443+
return $this->export($value);
14481444
}
14491445

14501446
/**
@@ -1513,13 +1509,13 @@ private function getServiceCall($id, Reference $reference = null)
15131509

15141510
if (null !== $reference && ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE !== $reference->getInvalidBehavior()) {
15151511
return sprintf('$this->get(\'%s\', ContainerInterface::NULL_ON_INVALID_REFERENCE)', $id);
1516-
} else {
1517-
if ($this->container->hasAlias($id)) {
1518-
$id = (string) $this->container->getAlias($id);
1519-
}
1512+
}
15201513

1521-
return sprintf('$this->get(\'%s\')', $id);
1514+
if ($this->container->hasAlias($id)) {
1515+
$id = (string) $ 6184 this->container->getAlias($id);
15221516
}
1517+
1518+
return sprintf('$this->get(\'%s\')', $id);
15231519
}
15241520

15251521
/**

0 commit comments

Comments
 (0)
0