src/EventListener/SessionListener.php line 36

Open in your IDE?
  1. <?php
  2. /**
  3.  * Copyright (c) 2011-present Qualiteam software Ltd. All rights reserved.
  4.  * See https://www.x-cart.com/license-agreement.html for license details.
  5.  */
  6. namespace XCart\EventListener;
  7. use Psr\Container\ContainerInterface;
  8. use Symfony\Component\HttpKernel\Event\ResponseEvent;
  9. use XLite\Core\Database;
  10. final class SessionListener
  11. {
  12.     protected $container;
  13.     public function __construct(ContainerInterface $container null)
  14.     {
  15.         $this->container $container;
  16.     }
  17.     public function onKernelResponse(ResponseEvent $event): void
  18.     {
  19.         if (!$event->isMainRequest() || $event->getRequest()->getMethod() === 'OPTIONS') {
  20.             return;
  21.         }
  22.         $session $this->container && $this->container->has('initialized_session')
  23.             ? $this->container->get('initialized_session')
  24.             : $event->getRequest()->getSession();
  25.         if (
  26.             $session
  27.             && $session->isStarted()
  28.             && $session->has('profile_id')
  29.             && $profile Database::getRepo('XLite\Model\Profile')->find($session->get('profile_id'))
  30.         ) {
  31.             $session->set('salt'$profile->getSalt());
  32.         }
  33.     }
  34. }