infinito/application/src/DataFixtures/DummyFixtures.php

40 lines
975 B
PHP
Raw Normal View History

2018-11-03 15:53:05 +01:00
<?php
2018-11-04 11:36:40 +01:00
namespace App\DataFixtures;
2018-11-03 15:53:05 +01:00
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\Persistence\ObjectManager;
use App\Entity\User;
2018-11-23 19:10:24 +01:00
use FOS\UserBundle\Util\PasswordUpdater;
use FOS\UserBundle\Doctrine\UserManager;
2018-11-04 11:36:40 +01:00
2018-11-04 11:53:36 +01:00
/**
* Never execute this fixture on a livesystem!
*
2018-11-04 12:25:53 +01:00
* @author kevinfrantz
2018-11-04 11:53:36 +01:00
*/
class DummyFixtures extends Fixture
2018-11-03 15:53:05 +01:00
{
public function load(ObjectManager $manager)
{
2018-11-23 19:10:24 +01:00
$this->addTestUser();
$manager->flush();
2018-11-03 15:53:05 +01:00
}
2018-11-23 19:10:24 +01:00
protected function addTestUser():void{
/**
* @var UserManager $userManager
*/
$userManager = $this->container->get('fos_user.user_manager');
/**
* @var User $testUser
*/
$testUser = $userManager->createUser();
$testUser->setEmail("test@test.de");
$testUser->setUsername("test");
$testUser->setPlainPassword('test');
$testUser->setEnabled(true);
$userManager->updateUser($testUser);
2018-11-03 15:53:05 +01:00
}
2018-11-04 11:36:40 +01:00
}