/**
  * Update last login date
  *
  * @param InteractiveLoginEvent $event Interactive login event
  *
  * @return $this Self object
  */
 public function updateLastLogin(InteractiveLoginEvent $event)
 {
     $user = $event->getAuthenticationToken()->getUser();
     if ($user instanceof LastLoginInterface) {
         $now = $this->dateTimeFactory->create();
         $user->setLastLoginAt($now);
         $this->objectManagerProvider->getManagerByEntityNamespace(get_class($user))->flush($user);
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * /token/event.pixel
  *
  * @param string $token Event
  * @param string $event Token
  *
  * @return Response Empty response
  */
 public function addEntryAction($token, $event)
 {
     $requestQuery = $this->requestStack->getCurrentRequest()->query;
     $value = $requestQuery->get('i', 0);
     $type = (int) $requestQuery->get('t', ElcodiMetricTypes::TYPE_BEACON_ALL);
     $this->metricManager->addEntry($token, $event, $value, $type, $this->dateTimeFactory->create());
     $content = base64_decode(self::IMAGE_CONTENT);
     $response = new Response($content);
     $response->setPrivate();
     $response->headers->addCacheControlDirective('no-cache', true);
     $response->headers->addCacheControlDirective('must-revalidate', true);
     $response->headers->set('Content-Type', 'image/png');
     return $response;
 }
Esempio n. 3
0
 /**
  * Check if a coupon is currently active.
  *
  * @param CouponInterface $coupon Coupon to check activeness
  * @param DateTime        $now
  *
  * @return bool
  */
 private function isActive(CouponInterface $coupon, \DateTime $now = null)
 {
     if (!$coupon->isEnabled()) {
         return false;
     }
     $now = $now ?: $this->dateTimeFactory->create();
     if ($coupon->getValidFrom() > $now) {
         return false;
     }
     $validTo = $coupon->getValidTo();
     if ($validTo && $now > $validTo) {
         return false;
     }
     return true;
 }
Esempio n. 4
0
 /**
  * Get now.
  *
  * @return DateTime Now
  */
 public function now()
 {
     return $this->dateTimeFactory->create();
 }