protected function generateCoreSelectorMenu(Site $site, string $uriToRedirectTo = null)
    {
        if (!$this->view instanceof BackendTemplateView) {
            throw new InvalidViewObjectNameException(vsprintf(
                'The controller "%s" must use BackendTemplateView to be able to generate menu for backends docheader. \
                Please set `protected $defaultViewObjectName = BackendTemplateView::class;` field in your controller.',
                [static::class]), 1493804179);
        }
        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());

        $this->coreSelectorMenu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
        $this->coreSelectorMenu->setIdentifier('component_core_selector_menu');

        if (!isset($uriToRedirectTo)) {
            $uriToRedirectTo = $this->uriBuilder->reset()->uriFor();
        }

        $this->initializeSelectedSolrCoreConnection();
        $cores = $this->solrConnectionManager->getConnectionsBySite($site);
        foreach ($cores as $core) {
            $coreAdmin = $core->getAdminService();
            $menuItem = $this->coreSelectorMenu->makeMenuItem();
            $menuItem->setTitle($coreAdmin->getCorePath());
            $uri = $this->uriBuilder->reset()->uriFor('switchCore',
                [
                    'corePath' => $coreAdmin->getCorePath(),
                    'uriToRedirectTo' => $uriToRedirectTo
                ]
            );
            $menuItem->setHref($uri);

            if ($coreAdmin->getCorePath() == $this->selectedSolrCoreConnection->getAdminService()->getCorePath()) {
                $menuItem->setActive(true);
            }
            $this->coreSelectorMenu->addMenuItem($menuItem);
        }

        $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($this->coreSelectorMenu);
    }
protected function generateCoreSelectorMenu(Site $site, string $uriToRedirectTo = null)
    {
        if (!$this->view instanceof BackendTemplateView) {
            throw new InvalidViewObjectNameException(vsprintf(
                'The controller "%s" must use BackendTemplateView to be able to generate menu for backends docheader. \
                Please set `protected $defaultViewObjectName = BackendTemplateView::class;` field in your controller.',
                [static::class]), 1493804179);
        }
        $this->view->getModuleTemplate()->setFlashMessageQueue($this->controllerContext->getFlashMessageQueue());

        $this->coreSelectorMenu = $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->makeMenu();
        $this->coreSelectorMenu->setIdentifier('component_core_selector_menu');

        if (!isset($uriToRedirectTo)) {
            $uriToRedirectTo = $this->uriBuilder->reset()->uriFor();
        }

        $this->initializeSelectedSolrCoreConnection();
        $cores = $this->solrConnectionManager->getConnectionsBySite($site);
        foreach ($cores as $core) {
            $coreAdmin = $core->getAdminService();
            $menuItem = $this->coreSelectorMenu->makeMenuItem();
            $menuItem->setTitle($coreAdmin->getCorePath());
            $uri = $this->uriBuilder->reset()->uriFor('switchCore',
                [
                    'corePath' => $coreAdmin->getCorePath(),
                    'uriToRedirectTo' => $uriToRedirectTo
                ]
            );
            $menuItem->setHref($uri);

            if ($coreAdmin->getCorePath() == $this->selectedSolrCoreConnection->getAdminService()->getCorePath()) {
                $menuItem->setActive(true);
            }
            $this->coreSelectorMenu->addMenuItem($menuItem);
        }

        $this->view->getModuleTemplate()->getDocHeaderComponent()->getMenuRegistry()->addMenu($this->coreSelectorMenu);
    }
protected function generateCoreSelectorMenu ( Site $ site , string $ uriToRedirectTo = null ) { if ( ! $ this -> view instanceof BackendTemplateView ) { throw new InvalidViewObjectNameException ( vsprintf ( 'The controller "%s" must use BackendTemplateView to be able to generate menu for backends docheader. \
                Please set `protected $defaultViewObjectName = BackendTemplateView::class;` field in your controller.' , [ static :: class ] ) , 1493804179 ) ; } $ this -> view -> getModuleTemplate ( ) -> setFlashMessageQueue ( $ this -> controllerContext -> getFlashMessageQueue ( ) ) ; $ this -> coreSelectorMenu = $ this -> view -> getModuleTemplate ( ) -> getDocHeaderComponent ( ) -> getMenuRegistry ( ) -> makeMenu ( ) ; $ this -> coreSelectorMenu -> setIdentifier ( 'component_core_selector_menu' ) ; if ( ! isset ( $ uriToRedirectTo ) ) { $ uriToRedirectTo = $ this -> uriBuilder -> reset ( ) -> uriFor ( ) ; } $ this -> initializeSelectedSolrCoreConnection ( ) ; $ cores = $ this -> solrConnectionManager -> getConnectionsBySite ( $ site ) ; foreach ( $ cores as $ core ) { $ coreAdmin = $ core -> getAdminService ( ) ; $ menuItem = $ this -> coreSelectorMenu -> makeMenuItem ( ) ; $ menuItem -> setTitle ( $ coreAdmin -> getCorePath ( ) ) ; $ uri = $ this -> uriBuilder -> reset ( ) -> uriFor ( 'switchCore' , [ 'corePath' => $ coreAdmin -> getCorePath ( ) , 'uriToRedirectTo' => $ uriToRedirectTo ] ) ; $ menuItem -> setHref ( $ uri ) ; if ( $ coreAdmin -> getCorePath ( ) == $ this -> selectedSolrCoreConnection -> getAdminService ( ) -> getCorePath ( ) ) { $ menuItem -> setActive ( true ) ; } $ this -> coreSelectorMenu -> addMenuItem ( $ menuItem ) ; } $ this -> view -> getModuleTemplate ( ) -> getDocHeaderComponent ( ) -> getMenuRegistry ( ) -> addMenu ( $ this -> coreSelectorMenu ) ; }
Generates Core selector Menu for given Site.

@param Site $site
@param string|null $uriToRedirectTo
@throws InvalidViewObjectNameException
Generates Core selector Menu for given Site .