|
|
@ -2,7 +2,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
/* For licensing terms, see /license.txt */ |
|
|
|
|
|
|
|
|
|
|
|
namespace Chamilo\CoreBundle\EventListener; |
|
|
|
namespace Chamilo\CoreBundle\EventSubscriber; |
|
|
|
|
|
|
|
|
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
|
|
use Chamilo\CoreBundle\Entity\Course; |
|
|
|
use Chamilo\CoreBundle\Manager\SettingsManager; |
|
|
|
use Chamilo\CoreBundle\Manager\SettingsManager; |
|
|
@ -12,26 +12,20 @@ use Symfony\Component\HttpKernel\Event\RequestEvent; |
|
|
|
use Symfony\Component\HttpKernel\KernelEvents; |
|
|
|
use Symfony\Component\HttpKernel\KernelEvents; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Class LocaleListener |
|
|
|
|
|
|
|
* Checks the portal listener depending of different settings: |
|
|
|
* Checks the portal listener depending of different settings: |
|
|
|
* platform, user, course. |
|
|
|
* platform, user, course. |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
class LocaleListener implements EventSubscriberInterface |
|
|
|
class LocaleSubscriber implements EventSubscriberInterface |
|
|
|
{ |
|
|
|
{ |
|
|
|
protected $settingsManager; |
|
|
|
|
|
|
|
protected $defaultLocale; |
|
|
|
protected $defaultLocale; |
|
|
|
protected $paremeterBag; |
|
|
|
protected $parameterBag; |
|
|
|
|
|
|
|
protected $settingsManager; |
|
|
|
/** |
|
|
|
|
|
|
|
* LocaleListener constructor. |
|
|
|
public function __construct(string $defaultLocale, SettingsManager $settingsManager, ParameterBagInterface $parameterBag) |
|
|
|
* |
|
|
|
|
|
|
|
* @param string $defaultLocale |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public function __construct($defaultLocale, SettingsManager $settingsManager, ParameterBagInterface $paremeterBag) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
$this->defaultLocale = $defaultLocale; |
|
|
|
$this->defaultLocale = $defaultLocale; |
|
|
|
$this->settingsManager = $settingsManager; |
|
|
|
$this->settingsManager = $settingsManager; |
|
|
|
$this->paremeterBag = $paremeterBag; |
|
|
|
$this->parameterBag = $parameterBag; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public function onKernelRequest(RequestEvent $event) |
|
|
|
public function onKernelRequest(RequestEvent $event) |
|
|
@ -40,12 +34,16 @@ class LocaleListener implements EventSubscriberInterface |
|
|
|
if (!$request->hasPreviousSession()) { |
|
|
|
if (!$request->hasPreviousSession()) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
$installed = 1 === (int) $this->paremeterBag->get('installed'); |
|
|
|
$installed = 1 === (int) $this->parameterBag->get('installed'); |
|
|
|
|
|
|
|
|
|
|
|
if (!$installed) { |
|
|
|
if (!$installed) { |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (false === $request->hasSession()) { |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
$loadFromDb = $request->getSession()->get('check_locale_from_db', true); |
|
|
|
$loadFromDb = $request->getSession()->get('check_locale_from_db', true); |
|
|
|
|
|
|
|
|
|
|
|
if (false === $loadFromDb && |
|
|
|
if (false === $loadFromDb && |
|
|
@ -142,14 +140,11 @@ class LocaleListener implements EventSubscriberInterface |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* @return array |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public static function getSubscribedEvents() |
|
|
|
public static function getSubscribedEvents() |
|
|
|
{ |
|
|
|
{ |
|
|
|
return [ |
|
|
|
return [ |
|
|
|
// must be registered before the default Locale listener |
|
|
|
// must be registered before the default Locale listener |
|
|
|
KernelEvents::REQUEST => [['onKernelRequest', 15]], |
|
|
|
KernelEvents::REQUEST => [['onKernelRequest', 20]], |
|
|
|
]; |
|
|
|
]; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |