/** * Método para cargar usuarios de prueba */ private function loadUsers(ObjectManager $manager, $username, $email, $password, $roles) { $date = new \DateTime(date('Y-m-d H:i:s')); $user = new Users(); $user->setSalt(md5(uniqid(null, true))); $encoder = $this->container->get('security.password_encoder'); $pass = $encoder->encodePassword($password, $user->getSalt()); $user->setUsername($username); $user->setEmail($email); $user->setPassword($pass); $user->setActive(1); $user->setRoles($roles); $user->setCreatedAt($date); $user->setModifiedAt($date); $user->setCreatedBy(1); $manager->persist($user); unset($user); $manager->flush(); }