Files
Mangarr/src/DataFixtures/AppFixtures.php
Jérémy Guillot 9595831aa3 - début refonte graphique
- début MangaDbProvider
2024-06-05 00:05:28 +02:00

46 lines
1.2 KiB
PHP

<?php
namespace App\DataFixtures;
use App\Factory\ApiTokenFactory;
use App\Factory\ChapterFactory;
use App\Factory\MangaFactory;
use App\Factory\PageFactory;
use App\Factory\UserFactory;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class AppFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
UserFactory::createMany(20);
ApiTokenFactory::createMany(60, function () {
return [
'ownedBy' => UserFactory::random()
];
});
$mangas = MangaFactory::createMany(25);
foreach ($mangas as $manga) {
for ($i = 1; $i <= 5; $i++) {
$manga->addChapter(ChapterFactory::createOne([
'manga' => $manga,
'number' => $i
])->object());
}
foreach ($manga->getChapters() as $chapter) {
for ($i = 1; $i <= 5; $i++) {
$chapter->addPagesLink(PageFactory::createOne([
'chapter' => $chapter,
'number' => $i
])->object());
}
}
}
}
}