mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Add priority tag support For MenuBuilder
This commit is contained in:
parent
99b25e3abb
commit
e91ddfae33
@ -38,11 +38,26 @@ class MenuCompilerPass implements CompilerPassInterface
|
||||
|
||||
$menuComposerDefinition = $container->getDefinition('chill.main.menu_composer');
|
||||
|
||||
$services = [];
|
||||
foreach ($container->findTaggedServiceIds('chill.menu_builder') as $id => $tags) {
|
||||
$class = $container->getDefinition($id)->getClass();
|
||||
$services[] = [
|
||||
'id' => $id,
|
||||
'priority' => $tags[0]['priority'] ?? 100,
|
||||
];
|
||||
}
|
||||
|
||||
usort($services, function ($a, $b) {
|
||||
if ($a['priority'] == $b['priority']) {
|
||||
return 0;
|
||||
}
|
||||
return ($a['priority'] < $b['priority']) ? -1 : 1;
|
||||
});
|
||||
|
||||
foreach ($services as $service) {
|
||||
$class = $container->getDefinition($service['id'])->getClass();
|
||||
foreach ($class::getMenuIds() as $menuId) {
|
||||
$menuComposerDefinition
|
||||
->addMethodCall('addLocalMenuBuilder', [new Reference($id), $menuId]);
|
||||
->addMethodCall('addLocalMenuBuilder', [new Reference($service['id']), $menuId]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user