foreach ($container->
getParameter('security.firewalls'
) as $firewallName) { $firewallContextDefinition =
$container->
getDefinition('security.firewall.map.context.'.
$firewallName);
$this->
sortFirewallContextListeners($firewallContextDefinition,
$container);
} } private function sortFirewallContextListeners(Definition
$definition, ContainerBuilder
$container): void
{ /** @var IteratorArgument $listenerIteratorArgument */
$listenerIteratorArgument =
$definition->
getArgument(0
);
$prioritiesByServiceId =
$this->
getListenerPriorities($listenerIteratorArgument,
$container);
$listeners =
$listenerIteratorArgument->
getValues();
usort($listeners,
fn (Reference
$a, Reference
$b) =>
$prioritiesByServiceId[(string) $b] <=>
$prioritiesByServiceId[(string) $a]);
$listenerIteratorArgument->
setValues(array_values($listeners));
} private function getListenerPriorities(IteratorArgument
$listeners, ContainerBuilder
$container): array
{ $priorities =
[];