public function process(ContainerBuilder $container): void
    {
        // The the path ancestor matcher service.
        $definition = $container->getDefinition(PathAncestorMatcher::class);

        // Find the menu voter services and add them.
        $voters = [];
        foreach ($container->findTaggedServiceIds('knp_menu.voter') as $id => $tags) {
            $tag = $tags[0];

            $priority = isset($tag['priority']) ? (int) $tag['priority'] : 0;
            $voters[$priority][] = new Reference($id);
        }

        // Jump out if there are no voter services.
        if (empty($voters)) {
            return;
        }

        // Sort the voters and add them to the matcher.
        krsort($voters);
        $sortedVoters = call_user_func_array('array_merge', $voters);
        $definition->replaceArgument(0, $sortedVoters);
    }
public function process(ContainerBuilder $container): void
    {
        // The the path ancestor matcher service.
        $definition = $container->getDefinition(PathAncestorMatcher::class);

        // Find the menu voter services and add them.
        $voters = [];
        foreach ($container->findTaggedServiceIds('knp_menu.voter') as $id => $tags) {
            $tag = $tags[0];

            $priority = isset($tag['priority']) ? (int) $tag['priority'] : 0;
            $voters[$priority][] = new Reference($id);
        }

        // Jump out if there are no voter services.
        if (empty($voters)) {
            return;
        }

        // Sort the voters and add them to the matcher.
        krsort($voters);
        $sortedVoters = call_user_func_array('array_merge', $voters);
        $definition->replaceArgument(0, $sortedVoters);
    }
public function process ( ContainerBuilder $ container ) : void { // The the path ancestor matcher service. $ definition = $ container -> getDefinition ( PathAncestorMatcher :: class ) ; // Find the menu voter services and add them. $ voters = [ ] ; foreach ( $ container -> findTaggedServiceIds ( 'knp_menu.voter' ) as $ id => $ tags ) { $ tag = $ tags [ 0 ] ; $ priority = isset ( $ tag [ 'priority' ] ) ? ( int ) $ tag [ 'priority' ] : 0 ; $ voters [ $ priority ] [ ] = new Reference ( $ id ) ; } // Jump out if there are no voter services. if ( empty ( $ voters ) ) { return ; } // Sort the voters and add them to the matcher. krsort ( $ voters ) ; $ sortedVoters = call_user_func_array ( 'array_merge' , $ voters ) ; $ definition -> replaceArgument ( 0 , $ sortedVoters ) ; }
Add the menu voters to the path ancestor matcher.

@param ContainerBuilder $container The container builder.

@return void
Add the menu voters to the path ancestor matcher .