Code Duplication    Length = 15-17 lines in 7 locations

src/Chamilo/ThemeBundle/Controller/NavbarController.php 4 locations

@@ 26-42 (lines=17) @@
23
        return $this->get('event_dispatcher');
24
    }
25
26
    public function notificationsAction($max = 5)
27
    {
28
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_NOTIFICATIONS)) {
29
            return new Response();
30
        }
31
32
        $listEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_NOTIFICATIONS, new NotificationListEvent());
33
34
        return $this->render(
35
            'ChamiloThemeBundle:Navbar:notifications.html.twig',
36
            array(
37
                'notifications' => $listEvent->getNotifications(),
38
                'total' => $listEvent->getTotal(),
39
            )
40
        );
41
42
    }
43
44
    public function messagesAction($max = 5)
45
    {
@@ 44-60 (lines=17) @@
41
42
    }
43
44
    public function messagesAction($max = 5)
45
    {
46
47
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_MESSAGES)) {
48
            return new Response();
49
        }
50
51
        $listEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_MESSAGES, new MessageListEvent());
52
53
        return $this->render(
54
            'ChamiloThemeBundle:Navbar:messages.html.twig',
55
            array(
56
                'messages' => $listEvent->getMessages(),
57
                'total' => $listEvent->getTotal(),
58
            )
59
        );
60
    }
61
62
    public function tasksAction($max = 5)
63
    {
@@ 62-77 (lines=16) @@
59
        );
60
    }
61
62
    public function tasksAction($max = 5)
63
    {
64
65
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_TASKS)) {
66
            return new Response();
67
        }
68
        $listEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_TASKS, new TaskListEvent());
69
70
        return $this->render(
71
            'ChamiloThemeBundle:Navbar:tasks.html.twig',
72
            array(
73
                'tasks' => $listEvent->getTasks(),
74
                'total' => $listEvent->getTotal(),
75
            )
76
        );
77
    }
78
79
    public function userAction()
80
    {
@@ 79-93 (lines=15) @@
76
        );
77
    }
78
79
    public function userAction()
80
    {
81
82
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_NAVBAR_USER)) {
83
            return new Response();
84
        }
85
        $userEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_NAVBAR_USER, new ShowUserEvent());
86
87
        return $this->render(
88
            'ChamiloThemeBundle:Navbar:user.html.twig',
89
            array(
90
                'user' => $userEvent->getUser(),
91
            )
92
        );
93
    }
94
95
}
96

src/Chamilo/ThemeBundle/Controller/SidebarController.php 3 locations

@@ 28-42 (lines=15) @@
25
     * "Hello user" section
26
     * @return Response
27
     */
28
    public function userPanelAction()
29
    {
30
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_SIDEBAR_USER)) {
31
            return new Response();
32
        }
33
34
        $userEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_SIDEBAR_USER, new ShowUserEvent());
35
36
        return $this->render(
37
            'ChamiloThemeBundle:Sidebar:user-panel.html.twig',
38
            array(
39
                'user' => $userEvent->getUser()
40
            )
41
        );
42
    }
43
44
     /**
45
     * User menu section
@@ 48-62 (lines=15) @@
45
     * User menu section
46
     * @return Response
47
     */
48
    public function userProfileAction()
49
    {
50
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_SIDEBAR_USER)) {
51
            return new Response();
52
        }
53
54
        $userEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_SIDEBAR_USER, new ShowUserEvent());
55
56
        return $this->render(
57
            'ChamiloThemeBundle:Sidebar:user-profile.html.twig',
58
            array(
59
                'user' => $userEvent->getUser()
60
            )
61
        );
62
    }
63
64
      /**
65
     * User menu section
@@ 68-82 (lines=15) @@
65
     * User menu section
66
     * @return Response
67
     */
68
    public function socialPanelAction()
69
    {
70
        if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_SIDEBAR_USER)) {
71
            return new Response();
72
        }
73
74
        $userEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_SIDEBAR_USER, new ShowUserEvent());
75
76
        return $this->render(
77
            'ChamiloThemeBundle:Sidebar:social-panel.html.twig',
78
            array(
79
                'user' => $userEvent->getUser()
80
            )
81
        );
82
    }
83
84
    /**
85
     * Search bar