vendor/aropixel/tickandlive-shop/Infrastructure/Feature/Front/Checkout/Guest/GuestLogger.php line 43

Open in your IDE?
  1. <?php
  2. /**
  3.  * Créé par Aropixel @2022.
  4.  * Par: Joël Gomez Caballe
  5.  * Date: 19/06/2022 à 12:05
  6.  */
  7. namespace TickLive\ShopBundle\Infrastructure\Feature\Front\Checkout\Guest;
  8. use Symfony\Component\HttpFoundation\Session\SessionInterface;
  9. use TickLive\ShopBundle\Domain\Component\Ecommerce\Guest\GuestLoggerInterface;
  10. use TickLive\ShopBundle\Entity\Customer;
  11. class GuestLogger implements GuestLoggerInterface
  12. {
  13.     private SessionInterface $session;
  14.     /** @var string  */
  15.     const GUEST_LOG_KEY '_ticklive.guest';
  16.     /**
  17.      * @param SessionInterface $session
  18.      */
  19.     public function __construct(SessionInterface $session)
  20.     {
  21.         $this->session $session;
  22.     }
  23.     public function logIn(Customer $customer): void
  24.     {
  25.         $this->session->set(self::GUEST_LOG_KEY$customer->getId());
  26.         $this->session->save();
  27.     }
  28.     public function logOut(): void
  29.     {
  30.         $this->session->remove(self::GUEST_LOG_KEY);
  31.         $this->session->save();
  32.     }
  33.     public function isLogged(): bool
  34.     {
  35.         return $this->session->has(self::GUEST_LOG_KEY);
  36.     }
  37. }