load('services.yaml'); // NOTE: cannot use processConfiguration here since having the key as an identifier // will break across multiple configuration files. // Issue can be found here: https://github.com/symfony/symfony/issues/29817 $data = $this->processConfigs($configs); // set acl data for main acl generator // $def = $container->getDefinition('catalyst_menu.generator'); $def = $container->getDefinition('Catalyst\\MenuBundle\\Service\\Generator'); // $def->replaceArgument('$menu_data', $configs); $def->replaceArgument('$menu_data', $data); } protected function processConfigs($data) { $pdata = []; // error_log(print_r($data, true)); // manual array merge // first layer contains all the instances in config foreach ($data as $instance_data) { // 2nd layer are the groups and the parents foreach ($instance_data as $group => $group_data) { // initialize group data if (!isset($pdata[$group])) $pdata[$group] = $group_data; else { // append to group data foreach ($group_data as $menu_data) $pdata[$group][] = $menu_data; } } } // sort group data according to display priority foreach ($pdata as $group => $group_data) { usort($pdata[$group], function($a, $b) { if (isset($a['order'])) $a_order = $a['order']; else $a_order = self::ORDER_DEFAULT; if (isset($b['order'])) $b_order = $b['order']; else $b_order = self::ORDER_DEFAULT; return $a_order - $b_order; }); } return $pdata; } }