2016-03-29 06:53:06 +00:00
|
|
|
<?php
|
2023-04-01 18:23:30 +00:00
|
|
|
declare(strict_types=1);
|
2016-03-29 06:53:06 +00:00
|
|
|
|
2023-04-01 18:23:30 +00:00
|
|
|
namespace App\DataFixtures;
|
2016-03-29 06:53:06 +00:00
|
|
|
|
2023-04-01 18:23:30 +00:00
|
|
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
2016-03-29 06:53:06 +00:00
|
|
|
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
2023-04-01 18:23:30 +00:00
|
|
|
use Doctrine\Persistence\ObjectManager;
|
|
|
|
use App\Entity\User;
|
2016-03-29 06:53:06 +00:00
|
|
|
|
2023-04-01 18:23:30 +00:00
|
|
|
class LoadUserData extends Fixture implements OrderedFixtureInterface
|
2016-03-29 06:53:06 +00:00
|
|
|
{
|
2019-04-03 15:38:53 +00:00
|
|
|
public const USER_MAIN_ID = 99999;
|
2019-04-03 16:19:03 +00:00
|
|
|
public const USER_SCND_ID = 99998;
|
|
|
|
public const USER_PRIV_ID = 99997;
|
|
|
|
public const USER_WLON_ID = 99996;
|
|
|
|
public const USER_PRWL_ID = 99995;
|
|
|
|
public const USER_UNNM_ID = 99994;
|
2019-04-03 15:38:53 +00:00
|
|
|
|
2016-12-11 22:53:56 +00:00
|
|
|
private $users = [
|
2019-04-03 15:38:53 +00:00
|
|
|
['id' => self::USER_MAIN_ID, 'login' => 'testuser', 'name' => 'Test User 1', 'private' => false, 'whitelist-only' => false],
|
2019-04-03 16:19:03 +00:00
|
|
|
['id' => self::USER_SCND_ID, 'login' => 'testuser2', 'name' => 'Test User 2 for autocomplete test', 'private' => false, 'whitelist-only' => false],
|
2019-04-03 15:38:53 +00:00
|
|
|
['id' => self::USER_PRIV_ID, 'login' => 'private_user', 'name' => 'Test User 3', 'private' => true, 'whitelist-only' => false],
|
|
|
|
['id' => self::USER_WLON_ID, 'login' => 'whitelist_only_user', 'name' => 'Test User 4', 'private' => false, 'whitelist-only' => true],
|
|
|
|
['id' => self::USER_PRWL_ID, 'login' => 'private_whitelist_only_user', 'name' => 'Test User 4', 'private' => false, 'whitelist-only' => true],
|
|
|
|
['id' => self::USER_UNNM_ID, 'login' => 'unnamed_user', 'name' => null, 'private' => false, 'whitelist-only' => false],
|
2016-12-11 22:53:56 +00:00
|
|
|
];
|
|
|
|
|
2016-03-29 06:53:06 +00:00
|
|
|
public function load(ObjectManager $om)
|
|
|
|
{
|
2016-12-11 22:53:56 +00:00
|
|
|
foreach ($this->users as $userData) {
|
2019-04-03 15:38:53 +00:00
|
|
|
$user = new User($userData['id'], new \DateTime(), $userData['login'], $userData['name']);
|
|
|
|
$user->updatePrivacy(!$userData['private'], $userData['whitelist-only']);
|
2016-12-11 22:53:56 +00:00
|
|
|
|
|
|
|
$om->persist($user);
|
2016-03-29 06:53:06 +00:00
|
|
|
|
2016-12-11 22:53:56 +00:00
|
|
|
$this->addReference('test_user_'.$user->getId(), $user);
|
|
|
|
}
|
|
|
|
|
|
|
|
$om->flush();
|
2016-03-29 06:53:06 +00:00
|
|
|
}
|
|
|
|
|
2017-01-12 23:00:21 +00:00
|
|
|
public function getOrder(): int
|
2016-03-29 06:53:06 +00:00
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
2023-04-01 18:23:30 +00:00
|
|
|
}
|