/** * @param string $username * @throws \Symfony\Component\Security\Core\Exception\UsernameNotFoundException * @return \Symfony\Component\Security\Core\User\UserInterface */ public function loadUserByUsername($username) : UserInterface { if (($user = $this->manager->findUserByUsernameOrEmail($username)) === null) { throw new UsernameNotFoundException("Username \"{$username}\" does not exist."); } return $user; }