This commit is contained in:
Jérémy Guillot
2024-06-03 17:36:22 +02:00
commit bddcdd6823
73 changed files with 13150 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
<?php
namespace App\DataFixtures;
use App\Factory\ApiTokenFactory;
use App\Factory\CommentFactory;
use App\Factory\CompanyFactory;
use App\Factory\DocumentFactory;
use App\Factory\FolderFactory;
use App\Factory\ProjectDocumentFactory;
use App\Factory\ProjectFactory;
use App\Factory\UserFactory;
use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Persistence\ObjectManager;
class AppFixtures extends Fixture
{
public function load(ObjectManager $manager): void
{
CompanyFactory::createMany(5);
UserFactory::createMany(20, function () {
return [
'company' => CompanyFactory::random()
];
});
ApiTokenFactory::createMany(60, function () {
return [
'ownedBy' => UserFactory::random()
];
});
$projects = ProjectFactory::createMany(100, function () {
return [
'ownedBy' => UserFactory::random()
];
});
$documents = DocumentFactory::createMany(100);
foreach ($documents as $document) {
ProjectDocumentFactory::createMany(3, function () use ($document) {
return [
'document' => $document,
'project' => ProjectFactory::random()
];
});
CommentFactory::createMany(1, function () use ($document) {
return [
'projectDocument' => ProjectDocumentFactory::random(),
'postedBy' => UserFactory::random()
];
});
}
foreach ($projects as $project) {
$projectFolder = FolderFactory::createOne([
'label' => 'Root Folder Project ' . $project->getId(),
'slug' => 'root-folder-project-' . $project->getId(),
'project' => $project,
'createdBy' => $project->getOwnedBy()
]);
$child = FolderFactory::createOne([
'label' => 'Subfolder - Parent Folder: ' . $projectFolder->getId(),
'slug' => 'subfolder-parent-folder-' . $projectFolder->getId(),
'createdBy' => $project->getOwnedBy()
]);
$grandChild = FolderFactory::createOne([
'label' => 'Subfolder - Parent Folder: ' . $child->getId(),
'slug' => 'subfolder-parent-folder-' . $child->getId(),
'createdBy' => $project->getOwnedBy()
]);
$grandChild->addDocument(DocumentFactory::createOne()->object());
$grandChild->addDocument(DocumentFactory::createOne()->object());
$grandChild->addDocument(DocumentFactory::createOne()->object());
$child->addChild(
$grandChild->object()
);
$projectFolder->addChild(
$child->object()
);
}
}
}