mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-11 02:09:50 +00:00
datafixture relationship: attempt
This commit is contained in:
parent
d06a4b1ca9
commit
1d774b19e8
@ -106,6 +106,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
|
|
||||||
protected UserRepository $userRepository;
|
protected UserRepository $userRepository;
|
||||||
|
|
||||||
|
public const PERSON = 'person';
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Registry $workflowRegistry,
|
Registry $workflowRegistry,
|
||||||
SocialIssueRepository $socialIssueRepository,
|
SocialIssueRepository $socialIssueRepository,
|
||||||
@ -257,6 +259,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
|||||||
$manager->persist($person);
|
$manager->persist($person);
|
||||||
$manager->persist($accompanyingPeriod);
|
$manager->persist($accompanyingPeriod);
|
||||||
echo "add person'".$person->__toString()."'\n";
|
echo "add person'".$person->__toString()."'\n";
|
||||||
|
|
||||||
|
$this->addReference(self::PERSON, $person);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getRandomUser(): User
|
private function getRandomUser(): User
|
||||||
|
@ -6,17 +6,31 @@ namespace Chill\PersonBundle\DataFixtures\ORM;
|
|||||||
use Doctrine\Bundle\FixturesBundle\Fixture;
|
use Doctrine\Bundle\FixturesBundle\Fixture;
|
||||||
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
use Doctrine\Common\DataFixtures\DependentFixtureInterface;
|
||||||
use Doctrine\Persistence\ObjectManager;
|
use Doctrine\Persistence\ObjectManager;
|
||||||
|
use Chill\PersonBundle\DataFixtures\ORM\LoadPeople;
|
||||||
|
use Chill\PersonBundle\DataFixtures\ORM\LoadRelations;
|
||||||
|
use Chill\PersonBundle\Entity\Relationships\Relationship;
|
||||||
|
|
||||||
class LoadRelationships extends Fixture implements DependentFixtureInterface
|
class LoadRelationships extends Fixture implements DependentFixtureInterface
|
||||||
{
|
{
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public function getDependencies()
|
public function getDependencies()
|
||||||
{
|
{
|
||||||
|
return [
|
||||||
|
LoadPeople::class,
|
||||||
|
LoadRelations::class
|
||||||
|
];
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function load(ObjectManager $manager)
|
public function load(ObjectManager $manager)
|
||||||
{
|
{
|
||||||
|
$relationship = new Relationship;
|
||||||
|
$relationship->setFromPerson($this->getReference(LoadPeople::PERSON));
|
||||||
|
$relationship->setToPerson($this->getReference(LoadPeople::PERSON));
|
||||||
|
$relationship->setRelation($this->getReference(LoadRelations::RELATIONS));
|
||||||
|
$relationship->setReverse((bool)random_int(0, 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user