/** * Factory to create a credentials object from a user entity. * * @param User $user * * @return $this */ public static function fromEntity(User $user) { return new static($user->getUsername(), $user->getRoles(), $user->getApiKey(), $user->getLocale()); }
/** * Fixes the language cookie if the user's language doesn't match the default one. * * @param User $user * @param Request $request * @param Response $response */ private function fixCookie(User $user, Request $request, Response $response) { if ($request->cookies->get('language') === ($locale = $user->getLocale())) { return; } $response->headers->setCookie(new Cookie('language', $locale)); }
/** * Dispatches the mailer event. * * @param User $user * @param string $templateName * * @throws \LogicException */ private function dispatchNotificationEvent(User $user, string $templateName) { $this->accountBlockerProvider->addTemporaryBlockedAccountID($user->getId()); $this->notify(['notification_target' => $user, 'tracing_data' => $this->ipTracer->getIpLocationData($this->requestStack->getMasterRequest()->getClientIp(), $user->getLocale())], [$user], ['mail'], null, sprintf('AppBundle:Email/AuthAttempt:%s', $templateName)); }