EventSubscriber/UserMenuSubscriber.php
public function addInvitationsMenuItem(UserMenuCollectionEvent $event): void
    {
        // Get the menu from the event.
        $menu = $event->getMenu();

        // Lookup and count pending invitations.
        $repo = $this->em->getRepository(Invitation::class);
        $user = $this->token_storage->getToken()->getUser();
        $invitations = $repo->findPendingInvitations($user);

        // Create the pending invitations menu link.
        $invitations = $this->factory->createItem('menu_item.pending_invitations', [
            'route' => 'bkstg_invitation_index',
            'extras' => [
                'badge_count' => count($invitations),
                'translation_domain' => BkstgScheduleBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $menu->addChild($invitations);
    }
public function addInvitationsMenuItem(UserMenuCollectionEvent $event): void
    {
        // Get the menu from the event.
        $menu = $event->getMenu();

        // Lookup and count pending invitations.
        $repo = $this->em->getRepository(Invitation::class);
        $user = $this->token_storage->getToken()->getUser();
        $invitations = $repo->findPendingInvitations($user);

        // Create the pending invitations menu link.
        $invitations = $this->factory->createItem('menu_item.pending_invitations', [
            'route' => 'bkstg_invitation_index',
            'extras' => [
                'badge_count' => count($invitations),
                'translation_domain' => BkstgScheduleBundle::TRANSLATION_DOMAIN,
            ],
        ]);
        $menu->addChild($invitations);
    }
public function addInvitationsMenuItem ( UserMenuCollectionEvent $ event ) : void { // Get the menu from the event. $ menu = $ event -> getMenu ( ) ; // Lookup and count pending invitations. $ repo = $ this -> em -> getRepository ( Invitation :: class ) ; $ user = $ this -> token_storage -> getToken ( ) -> getUser ( ) ; $ invitations = $ repo -> findPendingInvitations ( $ user ) ; // Create the pending invitations menu link. $ invitations = $ this -> factory -> createItem ( 'menu_item.pending_invitations' , [ 'route' => 'bkstg_invitation_index' , 'extras' => [ 'badge_count' => count ( $ invitations ) , 'translation_domain' => BkstgScheduleBundle :: TRANSLATION_DOMAIN , ] , ] ) ; $ menu -> addChild ( $ invitations ) ; }
Add invitations menu item.

@param UserMenuCollectionEvent $event The menu collection event.

@return void
Add invitations menu item .