Files
Mangarr/src/DataFixtures/AppFixtures.php
Jérémy Guillot 291e85338a - Portage des fonctionnalités de la branche main
- Ajout de node et npm dans la Dockerfile

- Ajout des Factories et Fixtures

- Ajout de npm-install dans Make install
2024-06-03 19:41:24 +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(5);
foreach ($mangas as $manga) {
for ($i = 1; $i <= 10; $i++) {
$manga->addChapter(ChapterFactory::createOne([
'manga' => $manga,
'number' => $i
])->object());
}
foreach ($manga->getChapters() as $chapter) {
for ($i = 1; $i <= 15; $i++) {
$chapter->addPagesLink(PageFactory::createOne([
'chapter' => $chapter,
'number' => $i
])->object());
}
}
}
}
}