/** * {@inheritdoc} */ public function onKernelRequest(GetResponseEvent $event) { // Already set if (null !== $this->userDiscriminator->getCurrentUser()) { return; } $request = $event->getRequest(); foreach ($this->users as $name => $requestMatcher) { if ($requestMatcher->matches($request)) { $this->userDiscriminator->setCurrentUser($name); return; } } }
/** * This must be called on prePersist and preUpdate if the event is about a * user. * * @param UserInterface $user */ protected function updateUserFields(UserInterface $user) { if (null === $this->userDiscriminator) { $this->userDiscriminator = $this->container->get('rollerworks_multi_user.user_discriminator'); } // Can only use the user manager when there is an user-system active if (null === $this->userDiscriminator->getCurrentUser() || true !== $this->userDiscriminator->getCurrentUserConfig()->getConfig('use_listener', true)) { return; } if (null === $this->userManager) { $this->userManager = $this->container->get('fos_user.user_manager'); } $this->userManager->updateCanonicalFields($user); $this->userManager->updatePassword($user); }
public function dispatchSecurityImplicitLogin(Event $e) { if ($userSys = $this->userDiscriminator->getCurrentUser()) { $this->eventDispatcher->dispatch($userSys . '.security.implicit_login', $e); } }