Internal: Refactoring event listeners - refs BT#21561

pull/5423/head
Angel Fernando Quiroz Campos 1 year ago
parent 70a28f449b
commit d5c8fd4d38
  1. 4
      config/packages/security.yaml
  2. 2
      public/main/admin/course_edit.php
  3. 2
      src/CoreBundle/DataProvider/Extension/CDocumentExtension.php
  4. 4
      src/CoreBundle/Entity/Session.php
  5. 13
      src/CoreBundle/EventListener/AssetListener.php
  6. 22
      src/CoreBundle/EventListener/CidReqListener.php
  7. 28
      src/CoreBundle/EventListener/CourseAccessListener.php
  8. 14
      src/CoreBundle/EventListener/ExceptionListener.php
  9. 14
      src/CoreBundle/EventListener/HTTPExceptionListener.php
  10. 27
      src/CoreBundle/EventListener/LegacyListener.php
  11. 42
      src/CoreBundle/EventListener/LoginSuccessHandler.php
  12. 13
      src/CoreBundle/EventListener/LogoutListener.php
  13. 2
      src/CoreBundle/EventListener/OnlineListener.php
  14. 26
      src/CoreBundle/EventListener/SessionAccessListener.php
  15. 14
      src/CoreBundle/EventListener/SettingListener.php
  16. 34
      src/CoreBundle/EventListener/TwigListener.php
  17. 2
      src/CoreBundle/Filter/SidFilter.php
  18. 28
      src/CoreBundle/Resources/config/listeners.yml
  19. 2
      src/CoreBundle/Resources/config/services.yml
  20. 2
      src/CoreBundle/Security/Authorization/Voter/SessionVoter.php
  21. 4
      src/CoreBundle/ServiceHelper/CidReqHelper.php
  22. 2
      src/CourseBundle/Controller/CourseControllerInterface.php

@ -51,9 +51,9 @@ security:
ROLE_STUDENT_BOSS: [ROLE_STUDENT]
ROLE_INVITEE: [ROLE_STUDENT]
ROLE_CURRENT_COURSE_STUDENT: [ROLE_CURRENT_COURSE_STUDENT] # Set in the CourseListener
ROLE_CURRENT_COURSE_STUDENT: [ROLE_CURRENT_COURSE_STUDENT] # Set in the CidReqListener
ROLE_CURRENT_COURSE_TEACHER: [ROLE_CURRENT_COURSE_TEACHER, ROLE_CURRENT_COURSE_STUDENT] # Set in the course listener
ROLE_CURRENT_COURSE_GROUP_STUDENT: [ROLE_CURRENT_COURSE_GROUP_STUDENT] # Set in the CourseListener
ROLE_CURRENT_COURSE_GROUP_STUDENT: [ROLE_CURRENT_COURSE_GROUP_STUDENT] # Set in the CidReqListener
ROLE_CURRENT_COURSE_GROUP_TEACHER: [ROLE_CURRENT_COURSE_GROUP_TEACHER, ROLE_CURRENT_COURSE_GROUP_STUDENT]
ROLE_CURRENT_COURSE_SESSION_STUDENT: [ROLE_CURRENT_COURSE_SESSION_STUDENT]
ROLE_CURRENT_COURSE_SESSION_TEACHER: [ROLE_CURRENT_COURSE_SESSION_STUDENT, ROLE_CURRENT_COURSE_SESSION_TEACHER]

@ -296,7 +296,7 @@ if ($form->validate()) {
$course = $form->getSubmitValues();
$visibility = $course['visibility'];
// @todo should be check in the CourseListener
// @todo should be check in the CidReqListener
/*global $_configuration;
if (isset($_configuration[$urlId]) &&

@ -60,7 +60,7 @@ final class CDocumentExtension implements QueryCollectionExtensionInterface // ,
$request = $this->requestStack->getCurrentRequest();
// Listing documents must contain the resource node parent (resourceNode.parent) and the course (cid)
// At least the cid so the CourseListener can be called.
// At least the cid so the CidReqListener can be called.
$resourceParentId = $request->query->get('resourceNode_parent');
$courseId = $request->query->getInt('cid');

@ -910,7 +910,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
}
/**
* currentCourse is set in CourseListener.
* currentCourse is set in CidReqListener.
*/
public function getCurrentCourse(): ?Course
{
@ -918,7 +918,7 @@ class Session implements ResourceWithAccessUrlInterface, Stringable
}
/**
* currentCourse is set in CourseListener.
* currentCourse is set in CidReqListener.
*/
public function setCurrentCourse(Course $course): self
{

@ -8,10 +8,9 @@ namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\Asset;
use Chamilo\CoreBundle\Repository\AssetRepository;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Vich\UploaderBundle\Event\Event;
class AssetListener implements EventSubscriberInterface
class AssetListener
{
protected AssetRepository $assetRepository;
@ -20,7 +19,7 @@ class AssetListener implements EventSubscriberInterface
$this->assetRepository = $assetRepository;
}
public function onVichUploaderPostRemove(Event $event): void
public function __invoke(Event $event): void
{
/** @var Asset $asset */
$asset = $event->getObject();
@ -36,12 +35,4 @@ class AssetListener implements EventSubscriberInterface
}*/
}
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return ['vich_uploader.post_remove' => 'onVichUploaderPostRemove'];
}
}

@ -18,13 +18,10 @@ use Chamilo\CourseBundle\Controller\CourseControllerInterface;
use Chamilo\CourseBundle\Entity\CGroup;
use ChamiloSession;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
@ -33,17 +30,16 @@ use Symfony\Contracts\Translation\TranslatorInterface;
use Twig\Environment;
/**
* Class CourseListener.
* Sets the course and session objects in the controller that implements the CourseControllerInterface.
*/
class CourseListener implements EventSubscriberInterface
class CidReqListener
{
public function __construct(
private readonly Environment $twig,
private readonly AuthorizationCheckerInterface $authorizationChecker,
private readonly TranslatorInterface $translator,
private readonly EntityManagerInterface $entityManager,
private TokenStorageInterface $tokenStorage,
private readonly TokenStorageInterface $tokenStorage,
) {}
/**
@ -197,8 +193,6 @@ class CourseListener implements EventSubscriberInterface
}
}
public function onKernelResponse(ResponseEvent $event): void {}
/**
* Once the onKernelRequest was fired, we check if the course/session object were set and we inject them in the controller.
*/
@ -314,16 +308,4 @@ class CourseListener implements EventSubscriberInterface
return '';
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => ['onKernelRequest', 6],
KernelEvents::RESPONSE => 'onKernelResponse',
KernelEvents::CONTROLLER => 'onKernelController',
];
}
}

@ -9,31 +9,25 @@ namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\TrackECourseAccess;
use Chamilo\CourseBundle\Event\CourseAccess;
use Doctrine\ORM\EntityManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
/**
* In and outs of a course
* This listeners is always called when user enters the course home.
* This listener is always called when user enters the course home.
*/
class CourseAccessListener implements EventSubscriberInterface
class CourseAccessListener
{
protected EntityManager $em;
protected ?Request $request = null;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function setRequest(RequestStack $requestStack): void
{
public function __construct(
private readonly EntityManager $em,
RequestStack $requestStack
) {
$this->request = $requestStack->getCurrentRequest();
}
public function onCourseAccessEvent(CourseAccess $event): void
public function __invoke(CourseAccess $event): void
{
// CourseAccess
$user = $event->getUser();
@ -51,12 +45,4 @@ class CourseAccessListener implements EventSubscriberInterface
$this->em->persist($access);
$this->em->flush();
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return ['chamilo_course.course.access' => 'onCourseAccessEvent'];
}
}

@ -7,17 +7,15 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Exception\NotAllowedException;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Twig\Environment;
class ExceptionListener implements EventSubscriberInterface
class ExceptionListener
{
protected Environment $twig;
protected TokenStorageInterface $tokenStorage;
@ -30,7 +28,7 @@ class ExceptionListener implements EventSubscriberInterface
$this->router = $router;
}
public function onKernelException(ExceptionEvent $event): void
public function __invoke(ExceptionEvent $event): void
{
// You get the exception object from the received event
$exception = $event->getThrowable();
@ -80,12 +78,4 @@ class ExceptionListener implements EventSubscriberInterface
// sends the modified response object to the event
$event->setResponse($response);
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return [KernelEvents::EXCEPTION => 'onKernelException'];
}
}

@ -6,15 +6,13 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\EventListener;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Symfony\Component\HttpKernel\KernelEvents;
final class HTTPExceptionListener implements EventSubscriberInterface
final class HTTPExceptionListener
{
public function onKernelException(ExceptionEvent $event): void
public function __invoke(ExceptionEvent $event): void
{
$exception = $event->getThrowable();
if (!($exception instanceof HttpException)
@ -30,12 +28,4 @@ final class HTTPExceptionListener implements EventSubscriberInterface
$event->setResponse($response);
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return [KernelEvents::EXCEPTION => 'onKernelException'];
}
}

@ -11,14 +11,9 @@ use Chamilo\CoreBundle\Framework\Container;
use Chamilo\CoreBundle\Repository\Node\AccessUrlRepository;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Exception;
use Symfony\Bundle\FrameworkBundle\Routing\Router;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\DependencyInjection\ParameterBag\ParameterBagInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\HttpKernel\Event\RequestEvent;
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@ -29,7 +24,7 @@ use Twig\Environment;
* Works as old global.inc.php
* Setting old php requirements so pages inside main/* could work correctly.
*/
class LegacyListener implements EventSubscriberInterface
class LegacyListener
{
public function __construct(
private readonly Environment $twig,
@ -41,7 +36,7 @@ class LegacyListener implements EventSubscriberInterface
private readonly ContainerInterface $container,
) {}
public function onKernelRequest(RequestEvent $event): void
public function __invoke(RequestEvent $event): void
{
if (!$event->isMainRequest()) {
return;
@ -142,7 +137,7 @@ class LegacyListener implements EventSubscriberInterface
$twig->addGlobal('header_extra_content', $extraHeader);
// We set cid_reset = true if we enter inside a main/admin url
// CourseListener check this variable and deletes the course session
// CidReqListener check this variable and deletes the course session
if (str_contains((string) $request->get('name'), 'admin/')) {
$session->set('cid_reset', true);
} else {
@ -161,20 +156,4 @@ class LegacyListener implements EventSubscriberInterface
$session->set('access_url_id', $urlId);
}
public function onKernelResponse(ResponseEvent $event): void {}
public function onKernelController(ControllerEvent $event): void {}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => 'onKernelRequest',
KernelEvents::RESPONSE => 'onKernelResponse',
KernelEvents::CONTROLLER => 'onKernelController',
];
}
}

@ -17,7 +17,6 @@ use Chamilo\CoreBundle\ServiceHelper\LoginAttemptLogger;
use Chamilo\CoreBundle\Settings\SettingsManager;
use DateTime;
use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
@ -25,32 +24,17 @@ use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
use UserManager;
// class LoginSuccessHandler implements AuthenticationSuccessHandlerInterface
class LoginSuccessHandler implements EventSubscriberInterface
class LoginSuccessHandler
{
protected UrlGeneratorInterface $router;
protected AuthorizationCheckerInterface $checker;
protected SettingsManager $settingsManager;
protected EntityManagerInterface $entityManager;
private LoginAttemptLogger $loginAttemptLogger;
public function __construct(
UrlGeneratorInterface $urlGenerator,
AuthorizationCheckerInterface $checker,
SettingsManager $settingsManager,
EntityManagerInterface $entityManager,
LoginAttemptLogger $loginAttemptLogger
) {
$this->router = $urlGenerator;
$this->checker = $checker;
$this->settingsManager = $settingsManager;
$this->entityManager = $entityManager;
$this->loginAttemptLogger = $loginAttemptLogger;
}
/**
* @return null|RedirectResponse
*/
public function onSecurityInteractiveLogin(InteractiveLoginEvent $event)
private readonly UrlGeneratorInterface $router,
private readonly AuthorizationCheckerInterface $checker,
private readonly SettingsManager $settingsManager,
private readonly EntityManagerInterface $entityManager,
private readonly LoginAttemptLogger $loginAttemptLogger
) {}
public function __invoke(InteractiveLoginEvent $event): ?RedirectResponse
{
$request = $event->getRequest();
$session = $request->getSession();
@ -179,12 +163,4 @@ class LoginSuccessHandler implements EventSubscriberInterface
return $response;
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return ['security.interactive_login' => 'onSecurityInteractiveLogin'];
}
}

@ -13,14 +13,13 @@ use DateTime;
use DateTimeZone;
use Doctrine\ORM\EntityManagerInterface;
use Exception;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Symfony\Component\Security\Core\Authorization\AuthorizationCheckerInterface;
use Symfony\Component\Security\Http\Event\LogoutEvent;
class LogoutListener implements EventSubscriberInterface
class LogoutListener
{
protected UrlGeneratorInterface $router;
protected AuthorizationCheckerInterface $checker;
@ -42,7 +41,7 @@ class LogoutListener implements EventSubscriberInterface
/**
* @throws Exception
*/
public function onSymfonyComponentSecurityHttpEventLogoutEvent(LogoutEvent $event): ?RedirectResponse
public function __invoke(LogoutEvent $event): ?RedirectResponse
{
$request = $event->getRequest();
@ -78,12 +77,4 @@ class LogoutListener implements EventSubscriberInterface
return new RedirectResponse($login);
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return [LogoutEvent::class => ['onSymfonyComponentSecurityHttpEventLogoutEvent', 20]];
}
}

@ -30,7 +30,7 @@ class OnlineListener
/**
* Update the user "lastActivity" on each request.
*/
public function onCoreController(ControllerEvent $event): void
public function __invoke(ControllerEvent $event): void
{
/* Here we are checking that the current request is a "MASTER_REQUEST",
and ignore any subrequest in the process (for example when doing a

@ -9,27 +9,21 @@ namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Entity\TrackECourseAccess;
use Chamilo\CourseBundle\Event\SessionAccess;
use Doctrine\ORM\EntityManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
class SessionAccessListener implements EventSubscriberInterface
class SessionAccessListener
{
protected EntityManager $em;
protected ?Request $request = null;
public function __construct(EntityManager $em)
{
$this->em = $em;
}
public function setRequest(RequestStack $requestStack): void
{
public function __construct(
private readonly EntityManager $em,
RequestStack $requestStack
) {
$this->request = $requestStack->getCurrentRequest();
}
public function onSessionAccessEvent(SessionAccess $event): void
public function __invoke(SessionAccess $event): void
{
$user = $event->getUser();
$course = $event->getCourse();
@ -47,12 +41,4 @@ class SessionAccessListener implements EventSubscriberInterface
$this->em->persist($access);
$this->em->flush();
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return ['chamilo_course.course.session' => 'onSessionAccessEvent'];
}
}

@ -7,14 +7,12 @@ declare(strict_types=1);
namespace Chamilo\CoreBundle\EventListener;
use Sylius\Bundle\SettingsBundle\Event\SettingsEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\Request;
class SettingListener implements EventSubscriberInterface
class SettingListener
{
public function __construct() {}
public function onSettingPreSave(SettingsEvent $event): void
public function __invoke(SettingsEvent $event): void
{
/*$urlId = $this->container->get('request')->getSession()->get('access_url_id');
$url = $this->container->get('doctrine')->getRepository('ChamiloCoreBundle:AccessUrl')->find($urlId);
@ -25,12 +23,4 @@ class SettingListener implements EventSubscriberInterface
// $settings->setAccessUrl($url);
// $event->setArgument('url', $url);
}
/**
* @return array<string, mixed>
*/
public static function getSubscribedEvents(): array
{
return ['sylius.settings.pre_save' => 'onSettingPreSave'];
}
}

@ -8,8 +8,6 @@ namespace Chamilo\CoreBundle\EventListener;
use Chamilo\CoreBundle\Repository\ColorThemeRepository;
use Chamilo\CoreBundle\Repository\LanguageRepository;
use Chamilo\CoreBundle\Settings\SettingsManager;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpKernel\Event\ControllerEvent;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
@ -20,31 +18,18 @@ use Twig\Environment;
/**
* Twig-related event listener. For filters, look into ChamiloExtension.php.
*/
class TwigListener implements EventSubscriberInterface
class TwigListener
{
private SerializerInterface $serializer;
private Environment $twig;
private TokenStorageInterface $tokenStorage;
private SettingsManager $settingsManager;
private LanguageRepository $languageRepository;
public function __construct(
Environment $twig,
SerializerInterface $serializer,
TokenStorageInterface $tokenStorage,
SettingsManager $settingsManager,
LanguageRepository $languageRepository,
private readonly Environment $twig,
private readonly SerializerInterface $serializer,
private readonly TokenStorageInterface $tokenStorage,
private readonly LanguageRepository $languageRepository,
private readonly ColorThemeRepository $colorThemeRepository,
private readonly RouterInterface $router,
) {
$this->twig = $twig;
$this->tokenStorage = $tokenStorage;
$this->serializer = $serializer;
$this->settingsManager = $settingsManager;
$this->languageRepository = $languageRepository;
}
) {}
public function onControllerEvent(ControllerEvent $event): void
public function __invoke(ControllerEvent $event): void
{
$request = $event->getRequest();
$token = $this->tokenStorage->getToken();
@ -87,9 +72,4 @@ class TwigListener implements EventSubscriberInterface
$this->twig->addGlobal('color_theme_link', $link);
}
public static function getSubscribedEvents(): array
{
return [ControllerEvent::class => 'onControllerEvent'];
}
}

@ -73,7 +73,7 @@ class SidFilter extends AbstractFilter
true
);
// Session was set with a kernel request from CoreBundle\EventListener\CourseListener class
// Session was set with a kernel request from CoreBundle\EventListener\CidReqListener class
$session = $this->getSession();
if (null === $session) {

@ -7,43 +7,32 @@ services:
# Event listeners
Chamilo\CoreBundle\EventListener\AssetListener:
arguments:
- '@Chamilo\CoreBundle\Repository\AssetRepository'
tags:
- {name: kernel.event_listener, event: vich_uploader.post_remove}
Chamilo\CoreBundle\EventListener\CourseListener:
Chamilo\CoreBundle\EventListener\CidReqListener:
tags:
- {name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 6}
- {name: kernel.event_listener, event: kernel.response, method: onKernelResponse}
- {name: kernel.event_listener, event: kernel.controller, method: onKernelController}
# Sets the user access in a course listener
Chamilo\CoreBundle\EventListener\CourseAccessListener:
arguments:
- '@doctrine.orm.entity_manager'
calls:
- [setRequest, ['@request_stack']]
tags:
- {name: kernel.event_listener, event: chamilo_course.course.access, method: onCourseAccessEvent}
- {name: kernel.event_listener, event: chamilo_course.course.access}
# Sets the user access in a course session listener
Chamilo\CoreBundle\EventListener\SessionAccessListener:
arguments:
- '@doctrine.orm.entity_manager'
calls:
- [setRequest, ['@request_stack']]
tags:
- {name: kernel.event_listener, event: chamilo_course.course.session, method: onSessionAccessEvent}
- {name: kernel.event_listener, event: chamilo_course.course.session}
# Setting user
Chamilo\CoreBundle\EventListener\LegacyListener:
bind:
$container: '@service_container'
tags:
- {name: kernel.event_listener, event: kernel.request, method: onKernelRequest, priority: 7}
- {name: kernel.event_listener, event: kernel.response, method: onKernelResponse}
- {name: kernel.event_listener, event: kernel.controller, method: onKernelController}
- {name: kernel.event_listener, event: kernel.request, priority: 7}
# User locale listener
# Chamilo\CoreBundle\EventListener\UserLocaleListener:
@ -52,9 +41,8 @@ services:
# Settings listener
Chamilo\CoreBundle\EventListener\SettingListener:
arguments: ['@service_container']
tags:
- {name: kernel.event_listener, event: sylius.settings.pre_save, method: onSettingPreSave}
- {name: kernel.event_listener, event: sylius.settings.pre_save}
Chamilo\CoreBundle\EventListener\TwigListener:
tags:
@ -62,16 +50,13 @@ services:
# Auth listeners
Chamilo\CoreBundle\EventListener\LoginSuccessHandler:
arguments: ['@router', '@security.authorization_checker', '@Chamilo\CoreBundle\Settings\SettingsManager', '@doctrine.orm.entity_manager', '@Chamilo\CoreBundle\ServiceHelper\LoginAttemptLogger']
tags:
- {name: kernel.event_listener, event: security.interactive_login, method: onSecurityInteractiveLogin}
- {name: kernel.event_listener, event: security.interactive_login}
Chamilo\CoreBundle\EventListener\LogoutListener:
arguments: ['@router', '@security.authorization_checker', '@security.token_storage', '@doctrine.orm.entity_manager']
tags:
- name: kernel.event_listener
event: Symfony\Component\Security\Http\Event\LogoutEvent
dispatcher: security.event_dispatcher.main
priority: 20
Chamilo\CoreBundle\EventListener\HTTPExceptionListener:
@ -79,7 +64,6 @@ services:
- {name: kernel.event_listener, event: kernel.exception}
Chamilo\CoreBundle\EventListener\ExceptionListener:
arguments: ['@twig']
tags:
- {name: kernel.event_listener, event: kernel.exception}

@ -65,7 +65,7 @@ services:
# class: Chamilo\CoreBundle\EventListener\OnlineListener
# arguments: [@security.context, @doctrine.orm.entity_manager ]
# tags:
# - {name: kernel.event_listener, event: kernel.controller, method: onCoreController}
# - {name: kernel.event_listener, event: kernel.controller}
Chamilo\CoreBundle\Repository\AssetRepository: ~

@ -64,7 +64,7 @@ class SessionVoter extends Voter
}
// Checks if the current course was set up
// $session->getCurrentCourse() is set in the class CourseListener.
// $session->getCurrentCourse() is set in the class CidReqListener.
/** @var Session $session */
$session = $subject;
$currentCourse = $session->getCurrentCourse();

@ -8,13 +8,13 @@ namespace Chamilo\CoreBundle\ServiceHelper;
use Chamilo\CoreBundle\Entity\Course;
use Chamilo\CoreBundle\Entity\Session;
use Chamilo\CoreBundle\EventListener\CourseListener;
use Chamilo\CoreBundle\EventListener\CidReqListener;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\RequestStack;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
/**
* @see CourseListener::onKernelRequest()
* @see CidReqListener::onKernelRequest()
*/
class CidReqHelper
{

@ -12,7 +12,7 @@ use Chamilo\CoreBundle\Entity\Session;
/**
* CourseControllerInterface.
* This interface provides getters and setters to a controller.
* These functions are loaded when the CourseListener.php fires when a c_id/cidReq/ or courses/XXX/ parameter and
* These functions are loaded when the CidReqListener.php fires when a c_id/cidReq/ or courses/XXX/ parameter and
* the controller implements this interface. See the ResourceController class as an example.
* is loaded in the URL.
*/

Loading…
Cancel
Save