Skip to content

Commit 21290ff

Browse files
authored
Merge pull request #1204 from progrupa/3.2.x
Merge the provider priority fix into 3.x branch
2 parents 488d588 + cd1d700 commit 21290ff

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

DependencyInjection/Compiler/RegisterProvidersPass.php

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,18 @@ public function process(ContainerBuilder $container)
3030
$registry = $container->getDefinition('fos_elastica.provider_registry');
3131
$providers = $container->findTaggedServiceIds('fos_elastica.provider');
3232

33-
foreach ($providers as $providerId => $tags) {
33+
$providersByPriority = array();
34+
foreach ($providers as $id => $attributes) {
35+
$priority = isset($attributes[0]['priority']) ? $attributes[0]['priority'] : 0;
36+
$providersByPriority[$priority][$id] = $attributes;
37+
}
38+
39+
if (!empty($providersByPriority)){
40+
krsort($providersByPriority);
41+
$providersByPriority = call_user_func_array('array_merge', $providersByPriority);
42+
}
43+
44+
foreach ($providersByPriority as $providerId => $tags) {
3445
$index = $type = null;
3546
$class = $container->getDefinition($providerId)->getClass();
3647

0 commit comments

Comments
 (0)