Chamilo is a learning management system focused on ease of use and accessibility
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
chamilo-lms/src/Chamilo/CoreBundle/Controller/NavbarController.php

109 lines
2.9 KiB

<?php
/**
* NavbarController.php
* avanzu-admin
* Date: 23.02.14
*/
namespace Chamilo\CoreBundle\Controller;
//use Chamilo\ThemeBundle\Controller\NavbarController as AvanzuController;
use Chamilo\ThemeBundle\Event\MessageListEvent;
use Chamilo\ThemeBundle\Event\NotificationListEvent;
use Chamilo\ThemeBundle\Event\ShowUserEvent;
use Chamilo\ThemeBundle\Event\TaskListEvent;
use Chamilo\ThemeBundle\Event\ThemeEvents;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Component\EventDispatcher\EventDispatcher;
use Symfony\Component\HttpFoundation\Response;
/**
* Class NavbarController
* @package Chamilo\CoreBundle\Controller
*/
class NavbarController extends Controller
{
/**
* @return EventDispatcher
*/
protected function getDispatcher()
{
return $this->get('event_dispatcher');
}
public function notificationsAction($max = 5)
{
if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_NOTIFICATIONS)) {
return new Response();
}
$listEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_NOTIFICATIONS, new NotificationListEvent());
return $this->render(
'ChamiloThemeBundle:Navbar:notifications.html.twig',
array(
'notifications' => $listEvent->getNotifications(),
'total' => $listEvent->getTotal()
)
);
}
public function messagesAction($max = 5)
{
if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_MESSAGES)) {
return new Response();
}
$listEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_MESSAGES, new MessageListEvent());
return $this->render(
'ChamiloThemeBundle:Navbar:messages.html.twig',
array(
'messages' => $listEvent->getMessages(),
'total' => $listEvent->getTotal()
)
);
}
public function tasksAction($max = 5)
{
if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_TASKS)) {
return new Response();
}
$listEvent = $this->getDispatcher()->dispatch(ThemeEvents::THEME_TASKS, new TaskListEvent());
return $this->render(
'ChamiloThemeBundle:Navbar:tasks.html.twig',
array(
'tasks' => $listEvent->getTasks(),
'total' => $listEvent->getTotal()
)
);
}
public function userAction()
{
if (!$this->getDispatcher()->hasListeners(ThemeEvents::THEME_NAVBAR_USER)) {
return new Response();
}
$userEvent = $this->getDispatcher()->dispatch(
ThemeEvents::THEME_NAVBAR_USER,
new ShowUserEvent()
);
return $this->render(
'ChamiloCoreBundle:Navbar:user.html.twig',
array(
'user' => $userEvent->getUser()
)
);
}
}