mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-12 21:34:25 +00:00
adding addresses to accompanying period
This commit is contained in:
parent
081c1c5271
commit
a0ff6bbe03
@ -21,14 +21,18 @@
|
||||
|
||||
namespace Chill\PersonBundle\DataFixtures\ORM;
|
||||
|
||||
use Chill\MainBundle\Entity\PostalCode;
|
||||
use Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
use Chill\PersonBundle\Entity\SocialWork\SocialIssue;
|
||||
use Chill\ThirdPartyBundle\Entity\ThirdParty;
|
||||
use Doctrine\Common\DataFixtures\AbstractFixture;
|
||||
use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
|
||||
use Doctrine\Persistence\ObjectManager;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Faker\Factory;
|
||||
use Faker\Generator;
|
||||
use Nelmio\Alice\Loader\NativeLoader;
|
||||
use Nelmio\Alice\ObjectSet;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
|
||||
use Chill\MainBundle\Entity\Address;
|
||||
@ -215,6 +219,8 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
||||
$accompanyingPeriod->addSocialIssue($this->getRandomSocialIssue());
|
||||
|
||||
if (\random_int(0, 10) > 3) {
|
||||
$accompanyingPeriod->setAddressLocation($this->createAddress());
|
||||
$manager->persist($accompanyingPeriod->getAddressLocation());
|
||||
$workflow = $this->workflowRegistry->get($accompanyingPeriod);
|
||||
$workflow->apply($accompanyingPeriod, 'confirm');
|
||||
}
|
||||
@ -262,6 +268,29 @@ class LoadPeople extends AbstractFixture implements OrderedFixtureInterface, Con
|
||||
echo "add person'".$p->__toString()."'\n";
|
||||
}
|
||||
|
||||
private function createAddress(): Address
|
||||
{
|
||||
$loader = new NativeLoader();
|
||||
$objectSet = $loader->loadData([
|
||||
Address::class => [
|
||||
'address' => [
|
||||
'street' => '<fr_FR:streetName()>',
|
||||
'streetNumber' => '<fr_FR:buildingNumber()>',
|
||||
'validFrom' => '<dateTimeBetween(\'-1 year\', \'now\')>',
|
||||
'postCode' => $this->getPostalCode()
|
||||
],
|
||||
],
|
||||
]);
|
||||
|
||||
return $objectSet->getObjects()['address'];
|
||||
}
|
||||
|
||||
private function getPostalCode(): PostalCode
|
||||
{
|
||||
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)];
|
||||
|
||||
return $this->getReference($ref);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a random point
|
||||
|
Loading…
x
Reference in New Issue
Block a user