infinito/application/src/DataFixtures/DummyFixtures.php

40 lines
913 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\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:29:49 +01:00
protected function addTestUser(): void
{
2018-11-23 19:10:24 +01:00
/**
2018-11-23 19:29:49 +01:00
* @var UserManager
2018-11-23 19:10:24 +01:00
*/
$userManager = $this->container->get('fos_user.user_manager');
/**
2018-11-23 19:29:49 +01:00
* @var User
2018-11-23 19:10:24 +01:00
*/
$testUser = $userManager->createUser();
2018-11-23 19:29:49 +01:00
$testUser->setEmail('test@test.de');
$testUser->setUsername('test');
2018-11-23 19:10:24 +01:00
$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
}