21 lines
629 B
PHP
21 lines
629 B
PHP
|
<?php
|
||
|
|
||
|
use MapGuesser\PersistentData\Model\User;
|
||
|
use MapGuesser\Repository\UserRepository;
|
||
|
use MapGuesser\Util\UsernameGenerator;
|
||
|
use SokoWeb\Database\Query\Select;
|
||
|
|
||
|
$select = new Select(Container::$dbConnection);
|
||
|
$users = Container::$persistentDataManager->selectMultipleFromDb($select, User::class);
|
||
|
$userRepository = new UserRepository();
|
||
|
$usernameGenerator = new UsernameGenerator();
|
||
|
|
||
|
foreach ($users as $user) {
|
||
|
do {
|
||
|
$username = $usernameGenerator->generate();
|
||
|
} while ($userRepository->getByUsername($username));
|
||
|
|
||
|
$user->setUsername($username);
|
||
|
Container::$persistentDataManager->saveToDb($user);
|
||
|
}
|