/** * {@inheritdoc} */ public function getUser() { if ($this->user) { return $this->user; } $user = $this->userRepository->findOneByUsername('test'); if (!$user) { $contact = $this->contactRepository->createNew(); $contact->setFirstName('Max'); $contact->setLastName('Mustermann'); $this->entityManager->persist($contact); $user = $this->userRepository->createNew(); $this->setCredentials($user); $user->setSalt(''); $user->setLocale('en'); $user->setContact($contact); $this->entityManager->persist($user); } else { $this->setCredentials($user); } $this->entityManager->flush(); $this->user = $user; return $this->user; }