main/core/Listener/Tool/HomeListener.php
public function onDisplayDesktop(DisplayToolEvent $event)
    {
        $currentUser = $this->tokenStorage->getToken()->getUser();

        $allTabs = $this->finder->search(HomeTab::class, [
            'filters' => ['user' => $currentUser->getUuid()],
        ]);

        // Order tabs. We want :
        //   - Administration tabs to be at first
        //   - Tabs to be ordered by position
        // For this, we separate administration tabs and user ones, order them by position
        // and then concat all tabs with admin in first (I don't have a easier solution to achieve this)

        $adminTabs = [];
        $userTabs = [];
        foreach ($allTabs['data'] as $tab) {
            if (!empty($tab)) {
                // we use the define position for array keys for easier sort
                if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) {
                    $adminTabs[$tab['position']] = $tab;
                } else {
                    $userTabs[$tab['position']] = $tab;
                }
            }
        }

        // order tabs by position
        ksort($adminTabs);
        ksort($userTabs);

        // generate the final list of tabs
        $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs));

        // we rewrite tab position because an admin and a user tab may have the same position
        foreach ($orderedTabs as $index => &$tab) {
            $tab['position'] = $index;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:home.html.twig', [
                'editable' => true,
                'context' => [
                    'type' => Widget::CONTEXT_DESKTOP,
                ],
                'tabs' => $orderedTabs,
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
public function onDisplayDesktop(DisplayToolEvent $event)
    {
        $currentUser = $this->tokenStorage->getToken()->getUser();

        $allTabs = $this->finder->search(HomeTab::class, [
            'filters' => ['user' => $currentUser->getUuid()],
        ]);

        // Order tabs. We want :
        //   - Administration tabs to be at first
        //   - Tabs to be ordered by position
        // For this, we separate administration tabs and user ones, order them by position
        // and then concat all tabs with admin in first (I don't have a easier solution to achieve this)

        $adminTabs = [];
        $userTabs = [];
        foreach ($allTabs['data'] as $tab) {
            if (!empty($tab)) {
                // we use the define position for array keys for easier sort
                if (HomeTab::TYPE_ADMIN_DESKTOP === $tab['type']) {
                    $adminTabs[$tab['position']] = $tab;
                } else {
                    $userTabs[$tab['position']] = $tab;
                }
            }
        }

        // order tabs by position
        ksort($adminTabs);
        ksort($userTabs);

        // generate the final list of tabs
        $orderedTabs = array_merge(array_values($adminTabs), array_values($userTabs));

        // we rewrite tab position because an admin and a user tab may have the same position
        foreach ($orderedTabs as $index => &$tab) {
            $tab['position'] = $index;
        }

        $content = $this->templating->render(
            'ClarolineCoreBundle:tool:home.html.twig', [
                'editable' => true,
                'context' => [
                    'type' => Widget::CONTEXT_DESKTOP,
                ],
                'tabs' => $orderedTabs,
            ]
        );

        $event->setContent($content);
        $event->stopPropagation();
    }
public function onDisplayDesktop ( DisplayToolEvent $ event ) { $ currentUser = $ this -> tokenStorage -> getToken ( ) -> getUser ( ) ; $ allTabs = $ this -> finder -> search ( HomeTab :: class , [ 'filters' => [ 'user' => $ currentUser -> getUuid ( ) ] , ] ) ; // Order tabs. We want : //   - Administration tabs to be at first //   - Tabs to be ordered by position // For this, we separate administration tabs and user ones, order them by position // and then concat all tabs with admin in first (I don't have a easier solution to achieve this) $ adminTabs = [ ] ; $ userTabs = [ ] ; foreach ( $ allTabs [ 'data' ] as $ tab ) { if ( ! empty ( $ tab ) ) { // we use the define position for array keys for easier sort if ( HomeTab :: TYPE_ADMIN_DESKTOP === $ tab [ 'type' ] ) { $ adminTabs [ $ tab [ 'position' ] ] = $ tab ; } else { $ userTabs [ $ tab [ 'position' ] ] = $ tab ; } } } // order tabs by position ksort ( $ adminTabs ) ; ksort ( $ userTabs ) ; // generate the final list of tabs $ orderedTabs = array_merge ( array_values ( $ adminTabs ) , array_values ( $ userTabs ) ) ; // we rewrite tab position because an admin and a user tab may have the same position foreach ( $ orderedTabs as $ index => & $ tab ) { $ tab [ 'position' ] = $ index ; } $ content = $ this -> templating -> render ( 'ClarolineCoreBundle:tool:home.html.twig' , [ 'editable' => true , 'context' => [ 'type' => Widget :: CONTEXT_DESKTOP , ] , 'tabs' => $ orderedTabs , ] ) ; $ event -> setContent ( $ content ) ; $ event -> stopPropagation ( ) ; }
Displays home on Desktop.

@DI\Observe("open_tool_desktop_home")

@param DisplayToolEvent $event
Displays home on Desktop .