Ajout endpoint API /projects + fixtures Project
This commit is contained in:
39
backend/src/DataFixtures/ProjectFixtures.php
Normal file
39
backend/src/DataFixtures/ProjectFixtures.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\DataFixtures;
|
||||
|
||||
use App\Entity\Project;
|
||||
use App\Entity\User;
|
||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||
use Doctrine\Common\Persistence\ObjectManager;
|
||||
|
||||
class ProjectFixtures extends Fixture implements DependentFixtureInterface
|
||||
{
|
||||
|
||||
public function load(ObjectManager $manager)
|
||||
{
|
||||
|
||||
$dev1 = $manager
|
||||
->getRepository(User::class)
|
||||
->findOneByUsername('dev1')
|
||||
;
|
||||
|
||||
$project1 = new Project();
|
||||
$project1->setName("Test");
|
||||
$project1->addUser($dev1);
|
||||
$manager->persist($project1);
|
||||
|
||||
$manager->flush();
|
||||
|
||||
}
|
||||
|
||||
public function getDependencies()
|
||||
{
|
||||
return [
|
||||
UserFixtures::class,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
}
|
Reference in New Issue
Block a user