Merge branch '329-gender-docgen-normalization' into 'master'

Normalize genderEntity for document generation

Closes #329

See merge request Chill-Projet/chill-bundles!762
This commit is contained in:
Julien Fastré 2024-11-29 11:01:54 +00:00
commit e043b0cf12
64 changed files with 351 additions and 171 deletions

View File

@ -0,0 +1,5 @@
kind: Fixed
body: Fix the serialization of gender for the generation of documents
time: 2024-11-28T13:48:34.528958771+01:00
custom:
Issue: "329"

View File

@ -12,8 +12,12 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM; namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\Activity; use Chill\ActivityBundle\Entity\Activity;
use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Entity\ActivityType;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -32,12 +36,12 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
$this->faker = FakerFactory::create('fr_FR'); $this->faker = FakerFactory::create('fr_FR');
} }
public function getOrder() public function getOrder(): int
{ {
return 16400; return 16400;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$persons = $this->em $persons = $this->em
->getRepository(Person::class) ->getRepository(Person::class)
@ -84,49 +88,41 @@ class LoadActivity extends AbstractFixture implements OrderedFixtureInterface
/** /**
* Return a random activityReason. * Return a random activityReason.
*
* @return \Chill\ActivityBundle\Entity\ActivityReason
*/ */
private function getRandomActivityReason() private function getRandomActivityReason(): ActivityReason
{ {
$reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)]; $reasonRef = LoadActivityReason::$references[array_rand(LoadActivityReason::$references)];
return $this->getReference($reasonRef); return $this->getReference($reasonRef, ActivityReason::class);
} }
/** /**
* Return a random activityType. * Return a random activityType.
*
* @return \Chill\ActivityBundle\Entity\ActivityType
*/ */
private function getRandomActivityType() private function getRandomActivityType(): ActivityType
{ {
$typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)]; $typeRef = LoadActivityType::$references[array_rand(LoadActivityType::$references)];
return $this->getReference($typeRef); return $this->getReference($typeRef, ActivityType::class);
} }
/** /**
* Return a random scope. * Return a random scope.
*
* @return \Chill\MainBundle\Entity\Scope
*/ */
private function getRandomScope() private function getRandomScope(): Scope
{ {
$scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)]; $scopeRef = LoadScopes::$references[array_rand(LoadScopes::$references)];
return $this->getReference($scopeRef); return $this->getReference($scopeRef, Scope::class);
} }
/** /**
* Return a random user. * Return a random user.
*
* @return \Chill\MainBundle\Entity\User
*/ */
private function getRandomUser() private function getRandomUser(): User
{ {
$userRef = array_rand(LoadUsers::$refs); $userRef = array_rand(LoadUsers::$refs);
return $this->getReference($userRef); return $this->getReference($userRef, User::class);
} }
} }

View File

@ -38,7 +38,7 @@ class LoadActivityNotifications extends AbstractFixture implements DependentFixt
], ],
]; ];
public function getDependencies() public function getDependencies(): array
{ {
return [ return [
LoadActivity::class, LoadActivity::class,

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM; namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityReason; use Chill\ActivityBundle\Entity\ActivityReason;
use Chill\ActivityBundle\Entity\ActivityReasonCategory;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -23,12 +24,12 @@ class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterf
{ {
public static $references = []; public static $references = [];
public function getOrder() public function getOrder(): int
{ {
return 16300; return 16300;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$reasons = [ $reasons = [
[ [
@ -56,7 +57,7 @@ class LoadActivityReason extends AbstractFixture implements OrderedFixtureInterf
$activityReason = (new ActivityReason()) $activityReason = (new ActivityReason())
->setName($r['name']) ->setName($r['name'])
->setActive(true) ->setActive(true)
->setCategory($this->getReference($r['category'])); ->setCategory($this->getReference($r['category'], ActivityReasonCategory::class));
$manager->persist($activityReason); $manager->persist($activityReason);
$reference = 'activity_reason_'.$r['name']['en']; $reference = 'activity_reason_'.$r['name']['en'];
$this->addReference($reference, $activityReason); $this->addReference($reference, $activityReason);

View File

@ -21,12 +21,12 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtureInterface class LoadActivityReasonCategory extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 16200; return 16200;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$categs = [ $categs = [
['name' => ['fr' => 'Logement', 'en' => 'Housing', 'nl' => 'Woning']], ['name' => ['fr' => 'Logement', 'en' => 'Housing', 'nl' => 'Woning']],

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ActivityBundle\DataFixtures\ORM; namespace Chill\ActivityBundle\DataFixtures\ORM;
use Chill\ActivityBundle\Entity\ActivityType; use Chill\ActivityBundle\Entity\ActivityType;
use Chill\ActivityBundle\Entity\ActivityTypeCategory;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -23,12 +24,12 @@ class LoadActivityType extends Fixture implements OrderedFixtureInterface
{ {
public static $references = []; public static $references = [];
public function getOrder() public function getOrder(): int
{ {
return 16100; return 16100;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$types = [ $types = [
// Exange // Exange
@ -57,7 +58,7 @@ class LoadActivityType extends Fixture implements OrderedFixtureInterface
echo 'Creating activity type : '.$t['name']['fr'].' (cat:'.$t['category']." \n"; echo 'Creating activity type : '.$t['name']['fr'].' (cat:'.$t['category']." \n";
$activityType = (new ActivityType()) $activityType = (new ActivityType())
->setName($t['name']) ->setName($t['name'])
->setCategory($this->getReference('activity_type_cat_'.$t['category'])) ->setCategory($this->getReference('activity_type_cat_'.$t['category'], ActivityTypeCategory::class))
->setSocialIssuesVisible(1) ->setSocialIssuesVisible(1)
->setSocialActionsVisible(1); ->setSocialActionsVisible(1);
$manager->persist($activityType); $manager->persist($activityType);

View File

@ -23,12 +23,12 @@ class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterfac
{ {
public static $references = []; public static $references = [];
public function getOrder() public function getOrder(): int
{ {
return 16050; return 16050;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$categories = [ $categories = [
[ [

View File

@ -15,7 +15,9 @@ use Chill\ActivityBundle\Security\Authorization\ActivityStatsVoter;
use Chill\ActivityBundle\Security\Authorization\ActivityVoter; use Chill\ActivityBundle\Security\Authorization\ActivityVoter;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -26,18 +28,18 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface class LoadActivitytACL extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 16000; return 16000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef); $scope = $this->getReference($scopeRef, Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {
case 'social': case 'social':

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\AsideActivityBundle\DataFixtures\ORM; namespace Chill\AsideActivityBundle\DataFixtures\ORM;
use Chill\AsideActivityBundle\Entity\AsideActivity; use Chill\AsideActivityBundle\Entity\AsideActivity;
use Chill\AsideActivityBundle\Entity\AsideActivityCategory;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Repository\UserRepository; use Chill\MainBundle\Repository\UserRepository;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
@ -30,7 +31,7 @@ class LoadAsideActivity extends Fixture implements DependentFixtureInterface
]; ];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$user = $this->userRepository->findOneBy(['username' => 'center a_social']); $user = $this->userRepository->findOneBy(['username' => 'center a_social']);
@ -43,7 +44,7 @@ class LoadAsideActivity extends Fixture implements DependentFixtureInterface
->setUpdatedAt(new \DateTimeImmutable('now')) ->setUpdatedAt(new \DateTimeImmutable('now'))
->setUpdatedBy($user) ->setUpdatedBy($user)
->setType( ->setType(
$this->getReference('aside_activity_category_0') $this->getReference('aside_activity_category_0', AsideActivityCategory::class)
) )
->setDate((new \DateTimeImmutable('today')) ->setDate((new \DateTimeImmutable('today'))
->sub(new \DateInterval('P'.\random_int(1, 100).'D'))); ->sub(new \DateInterval('P'.\random_int(1, 100).'D')));

View File

@ -16,7 +16,7 @@ use Doctrine\Persistence\ObjectManager;
class LoadAsideActivityCategory extends \Doctrine\Bundle\FixturesBundle\Fixture class LoadAsideActivityCategory extends \Doctrine\Bundle\FixturesBundle\Fixture
{ {
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach ( foreach (
[ [

View File

@ -37,7 +37,7 @@ class LoadCalendarACL extends Fixture implements OrderedFixtureInterface
foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) {
/** @var PermissionsGroup $group */ /** @var PermissionsGroup $group */
$group = $this->getReference($permissionGroupRef); $group = $this->getReference($permissionGroupRef, PermissionsGroup::class);
foreach ($roleScopes as $scope) { foreach ($roleScopes as $scope) {
$group->addRoleScope($scope); $group->addRoleScope($scope);

View File

@ -63,6 +63,6 @@ class LoadInvite extends Fixture implements FixtureGroupInterface
{ {
$userRef = array_rand(LoadUsers::$refs); $userRef = array_rand(LoadUsers::$refs);
return $this->getReference($userRef); return $this->getReference($userRef, User::class);
} }
} }

View File

@ -46,12 +46,12 @@ class LoadOption extends AbstractFixture implements OrderedFixtureInterface
$this->fakerNl = \Faker\Factory::create('nl_NL'); $this->fakerNl = \Faker\Factory::create('nl_NL');
} }
public function getOrder() public function getOrder(): int
{ {
return 1000; return 1000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "Loading Options \n"; echo "Loading Options \n";

View File

@ -23,7 +23,7 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadDocGeneratorTemplate extends AbstractFixture class LoadDocGeneratorTemplate extends AbstractFixture
{ {
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$templates = [ $templates = [
[ [

View File

@ -14,7 +14,9 @@ namespace Chill\DocStoreBundle\DataFixtures\ORM;
use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter; use Chill\DocStoreBundle\Security\Authorization\PersonDocumentVoter;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -24,19 +26,19 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface class LoadDocumentACL extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 35000; return 35000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
printf("processing permission group %s \n", $permissionsGroup->getName()); printf("processing permission group %s \n", $permissionsGroup->getName());
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef); $scope = $this->getReference($scopeRef, Scope::class);
printf("processing scope %s \n", $scope->getName()['en']); printf("processing scope %s \n", $scope->getName()['en']);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {

View File

@ -18,12 +18,12 @@ use Doctrine\Persistence\ObjectManager;
class LoadDocumentCategory extends AbstractFixture implements OrderedFixtureInterface class LoadDocumentCategory extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 35010; return 35010;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$category = (new DocumentCategory('chill-doc-store', 10)) $category = (new DocumentCategory('chill-doc-store', 10))
->setDocumentClass(\Chill\DocStoreBundle\Entity\PersonDocument::class) ->setDocumentClass(\Chill\DocStoreBundle\Entity\PersonDocument::class)

View File

@ -25,12 +25,12 @@ class LoadEventTypes extends AbstractFixture implements OrderedFixtureInterface
{ {
public static $refs = []; public static $refs = [];
public function getOrder() public function getOrder(): int
{ {
return 30000; return 30000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
/* /*
* Echange de savoirs * Echange de savoirs

View File

@ -12,9 +12,11 @@ declare(strict_types=1);
namespace Chill\EventBundle\DataFixtures\ORM; namespace Chill\EventBundle\DataFixtures\ORM;
use Chill\EventBundle\Entity\Event; use Chill\EventBundle\Entity\Event;
use Chill\EventBundle\Entity\EventType;
use Chill\EventBundle\Entity\Participation; use Chill\EventBundle\Entity\Participation;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -44,11 +46,12 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
$event = (new Event()) $event = (new Event())
->setDate($this->faker->dateTimeBetween('-2 years', '+6 months')) ->setDate($this->faker->dateTimeBetween('-2 years', '+6 months'))
->setName($this->faker->words(random_int(2, 4), true)) ->setName($this->faker->words(random_int(2, 4), true))
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)])) ->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)], EventType::class))
->setCenter($center) ->setCenter($center)
->setCircle( ->setCircle(
$this->getReference( $this->getReference(
LoadScopes::$references[array_rand(LoadScopes::$references)] LoadScopes::$references[array_rand(LoadScopes::$references)],
Scope::class
) )
); );
$manager->persist($event); $manager->persist($event);
@ -58,12 +61,12 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
return $events; return $events;
} }
public function getOrder() public function getOrder(): int
{ {
return 30010; return 30010;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$centers = $manager->getRepository(Center::class) $centers = $manager->getRepository(Center::class)
->findAll(); ->findAll();

View File

@ -13,7 +13,9 @@ namespace Chill\EventBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -23,18 +25,18 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface class LoadRolesACL extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 30011; return 30011;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef); $scope = $this->getReference($scopeRef, Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {
case 'social': case 'social':

View File

@ -45,7 +45,7 @@ class EventSearch extends AbstractSearch
private readonly PaginatorFactory $paginatorFactory, private readonly PaginatorFactory $paginatorFactory,
) {} ) {}
public function getOrder() public function getOrder(): int
{ {
return 3000; return 3000;
} }

View File

@ -19,25 +19,25 @@ use Doctrine\Persistence\ObjectManager;
*/ */
trait LoadAbstractNotificationsTrait trait LoadAbstractNotificationsTrait
{ {
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
return; return;
foreach ($this->notifs as $notif) { foreach ($this->notifs as $notif) {
$entityId = $this->getReference($notif['entityRef'])->getId(); $entityId = $this->getReference($notif['entityRef'], Notification::class)->getId();
echo 'Adding notification for '.$notif['entityClass'].'(entity id:'.$entityId.")\n"; echo 'Adding notification for '.$notif['entityClass'].'(entity id:'.$entityId.")\n";
$newNotif = (new Notification()) $newNotif = (new Notification())
->setMessage($notif['message']) ->setMessage($notif['message'])
->setSender($this->getReference($notif['sender'])) ->setSender($this->getReference($notif['sender'], Notification::class))
->setRelatedEntityClass($notif['entityClass']) ->setRelatedEntityClass($notif['entityClass'])
->setRelatedEntityId($entityId) ->setRelatedEntityId($entityId)
->setDate(new \DateTimeImmutable('now')) ->setDate(new \DateTimeImmutable('now'))
->setRead([]); ->setRead([]);
foreach ($notif['addressees'] as $addressee) { foreach ($notif['addressees'] as $addressee) {
$newNotif->addAddressee($this->getReference($addressee)); $newNotif->addAddressee($this->getReference($addressee, Notification::class));
} }
$manager->persist($newNotif); $manager->persist($newNotif);

View File

@ -13,6 +13,7 @@ namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Doctrine\Model\Point; use Chill\MainBundle\Doctrine\Model\Point;
use Chill\MainBundle\Entity\AddressReference; use Chill\MainBundle\Entity\AddressReference;
use Chill\MainBundle\Entity\PostalCode;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -33,12 +34,12 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
$this->faker = \Faker\Factory::create('fr_FR'); $this->faker = \Faker\Factory::create('fr_FR');
} }
public function getOrder() public function getOrder(): int
{ {
return 51; return 51;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "loading some reference address... \n"; echo "loading some reference address... \n";
@ -69,7 +70,8 @@ class LoadAddressReferences extends AbstractFixture implements ContainerAwareInt
$ar->setStreetNumber((string) random_int(0, 199)); $ar->setStreetNumber((string) random_int(0, 199));
$ar->setPoint($this->getRandomPoint()); $ar->setPoint($this->getRandomPoint());
$ar->setPostcode($this->getReference( $ar->setPostcode($this->getReference(
LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)] LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)],
PostalCode::class
)); ));
$ar->setMunicipalityCode($ar->getPostcode()->getCode()); $ar->setMunicipalityCode($ar->getPostcode()->getCode());

View File

@ -31,12 +31,12 @@ class LoadCenters extends AbstractFixture implements OrderedFixtureInterface
public static $refs = []; public static $refs = [];
public function getOrder() public function getOrder(): int
{ {
return 100; return 100;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (static::$centers as $new) { foreach (static::$centers as $new) {
$center = new Center(); $center = new Center();

View File

@ -25,12 +25,12 @@ class LoadCountries extends AbstractFixture implements ContainerAwareInterface,
{ {
private ?ContainerInterface $container = null; private ?ContainerInterface $container = null;
public function getOrder() public function getOrder(): int
{ {
return 20; return 20;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "loading countries... \n"; echo "loading countries... \n";

View File

@ -38,12 +38,12 @@ class LoadGenders extends AbstractFixture implements OrderedFixtureInterface
], ],
]; ];
public function getOrder() public function getOrder(): int
{ {
return 100; return 100;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "loading genders... \n"; echo "loading genders... \n";

View File

@ -11,7 +11,9 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\GroupCenter; use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\PermissionsGroup;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -20,18 +22,18 @@ class LoadGroupCenters extends AbstractFixture implements OrderedFixtureInterfac
{ {
public static $refs = []; public static $refs = [];
public function getOrder() public function getOrder(): int
{ {
return 500; return 500;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (LoadCenters::$refs as $centerRef) { foreach (LoadCenters::$refs as $centerRef) {
foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionGroupRef) {
$GroupCenter = new GroupCenter(); $GroupCenter = new GroupCenter();
$GroupCenter->setCenter($this->getReference($centerRef)); $GroupCenter->setCenter($this->getReference($centerRef, Center::class));
$GroupCenter->setPermissionsGroup($this->getReference($permissionGroupRef)); $GroupCenter->setPermissionsGroup($this->getReference($permissionGroupRef, PermissionsGroup::class));
$manager->persist($GroupCenter); $manager->persist($GroupCenter);

View File

@ -33,12 +33,12 @@ class LoadLanguages extends AbstractFixture implements ContainerAwareInterface,
// This array contains regional code to not exclude // This array contains regional code to not exclude
private array $regionalVersionToInclude = ['ro_MD']; private array $regionalVersionToInclude = ['ro_MD'];
public function getOrder() public function getOrder(): int
{ {
return 10; return 10;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "loading languages... \n"; echo "loading languages... \n";

View File

@ -25,7 +25,7 @@ class LoadLocationType extends AbstractFixture implements ContainerAwareInterfac
{ {
private ?ContainerInterface $container = null; private ?ContainerInterface $container = null;
public function getOrder() public function getOrder(): int
{ {
return 52; return 52;
} }

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\PermissionsGroup; use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -47,19 +48,19 @@ class LoadPermissionsGroup extends AbstractFixture implements OrderedFixtureInte
public static $refs = []; public static $refs = [];
public function getOrder() public function getOrder(): int
{ {
return 400; return 400;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (static::$permissionGroup as $new) { foreach (static::$permissionGroup as $new) {
$permissionGroup = new PermissionsGroup(); $permissionGroup = new PermissionsGroup();
$permissionGroup->setName($new['name']); $permissionGroup->setName($new['name']);
foreach ($new['role_scopes'] as $roleScopeRef) { foreach ($new['role_scopes'] as $roleScopeRef) {
$permissionGroup->addRoleScope($this->getReference($roleScopeRef)); $permissionGroup->addRoleScope($this->getReference($roleScopeRef, RoleScope::class));
} }
$manager->persist($permissionGroup); $manager->persist($permissionGroup);

View File

@ -325,12 +325,12 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface
85800,GIVRAND,FR,85100,46.6822701061,-1.8787272243,INSEE 85800,GIVRAND,FR,85100,46.6822701061,-1.8787272243,INSEE
EOF; EOF;
public function getOrder() public function getOrder(): int
{ {
return 50; return 50;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "loading postal codes... \n"; echo "loading postal codes... \n";
$this->loadPostalCodeCSV($manager, self::$postalCodeBelgium, 'BE'); $this->loadPostalCodeCSV($manager, self::$postalCodeBelgium, 'BE');
@ -365,7 +365,7 @@ class LoadPostalCodes extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($c); $manager->persist($c);
$ref = 'postal_code_'.$code[0]; $ref = 'postal_code_'.$code[0];
if (!$this->hasReference($ref)) { if (!$this->hasReference($ref, PostalCode::class)) {
$this->addReference($ref, $c); $this->addReference($ref, $c);
self::$refs[] = $ref; self::$refs[] = $ref;
} }

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -44,19 +45,19 @@ class LoadRoleScopes extends AbstractFixture implements OrderedFixtureInterface
public static $references = []; public static $references = [];
public function getOrder() public function getOrder(): int
{ {
return 300; return 300;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (static::$permissions as $key => $permission) { foreach (static::$permissions as $key => $permission) {
foreach (LoadScopes::$references as $scopeReference) { foreach (LoadScopes::$references as $scopeReference) {
$roleScope = new RoleScope(); $roleScope = new RoleScope();
$roleScope->setRole($key) $roleScope->setRole($key)
->setScope($this->getReference($scopeReference)); ->setScope($this->getReference($scopeReference, Scope::class));
$reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference)->getName()['en']; $reference = 'role_scope_'.$key.'_'.$this->getReference($scopeReference, Scope::class)->getName()['en'];
echo "Creating {$reference} \n"; echo "Creating {$reference} \n";
$this->addReference($reference, $roleScope); $this->addReference($reference, $roleScope);
$manager->persist($roleScope); $manager->persist($roleScope);

View File

@ -46,12 +46,12 @@ class LoadScopes extends AbstractFixture implements OrderedFixtureInterface
], ],
]; ];
public function getOrder() public function getOrder(): int
{ {
return 200; return 200;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach ($this->scopes as $new) { foreach ($this->scopes as $new) {
$scope = new \Chill\MainBundle\Entity\Scope(); $scope = new \Chill\MainBundle\Entity\Scope();

View File

@ -24,7 +24,7 @@ class LoadUserGroup extends Fixture implements FixtureGroupInterface
return ['user-group']; return ['user-group'];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$centerASocial = $manager->getRepository(User::class)->findOneBy(['username' => 'center a_social']); $centerASocial = $manager->getRepository(User::class)->findOneBy(['username' => 'center a_social']);
$centerBSocial = $manager->getRepository(User::class)->findOneBy(['username' => 'center b_social']); $centerBSocial = $manager->getRepository(User::class)->findOneBy(['username' => 'center b_social']);

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\MainBundle\DataFixtures\ORM; namespace Chill\MainBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\GroupCenter;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -54,12 +55,12 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
private ?ContainerInterface $container = null; private ?ContainerInterface $container = null;
public function getOrder() public function getOrder(): int
{ {
return 1000; return 1000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (self::$refs as $username => $params) { foreach (self::$refs as $username => $params) {
$user = new User(); $user = new User();
@ -80,7 +81,7 @@ class LoadUsers extends AbstractFixture implements ContainerAwareInterface, Orde
->setEmail(sprintf('%s@chill.social', \str_replace(' ', '', (string) $username))); ->setEmail(sprintf('%s@chill.social', \str_replace(' ', '', (string) $username)));
foreach ($params['groupCenterRefs'] as $groupCenterRef) { foreach ($params['groupCenterRefs'] as $groupCenterRef) {
$user->addGroupCenter($this->getReference($groupCenterRef)); $user->addGroupCenter($this->getReference($groupCenterRef, GroupCenter::class));
} }
echo 'Creating user '.$username."... \n"; echo 'Creating user '.$username."... \n";

View File

@ -21,13 +21,13 @@ use Symfony\Component\Validator\Constraints as Assert;
#[ORM\Table(name: 'chill_main_gender')] #[ORM\Table(name: 'chill_main_gender')]
class Gender class Gender
{ {
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read', 'docgen:read'])]
#[ORM\Id] #[ORM\Id]
#[ORM\GeneratedValue] #[ORM\GeneratedValue]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::INTEGER)]
private ?int $id = null; private ?int $id = null;
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read', 'docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::JSON)]
private array $label = []; private array $label = [];
@ -36,7 +36,7 @@ class Gender
private bool $active = true; private bool $active = true;
#[Assert\NotNull(message: 'You must choose a gender translation')] #[Assert\NotNull(message: 'You must choose a gender translation')]
#[Serializer\Groups(['read'])] #[Serializer\Groups(['read', 'docgen:read'])]
#[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, enumType: GenderEnum::class)] #[ORM\Column(type: \Doctrine\DBAL\Types\Types::STRING, enumType: GenderEnum::class)]
private GenderEnum $genderTranslation; private GenderEnum $genderTranslation;

View File

@ -34,10 +34,8 @@ interface SearchInterface
* the order in which the results will appears in the global view. * the order in which the results will appears in the global view.
* *
* (this may be eventually defined in config.yml) * (this may be eventually defined in config.yml)
*
* @return int
*/ */
public function getOrder(); public function getOrder(): int;
/** /**
* we may desactive the search interface by default. in this case, * we may desactive the search interface by default. in this case,

View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\MainBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Gender;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
class GenderDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
public function supportsNormalization($data, ?string $format = null, array $context = [])
{
return $data instanceof Gender;
}
public function normalize($gender, ?string $format = null, array $context = [])
{
return [
'id' => $gender->getId(),
'label' => $this->translatableStringHelper->localize($gender->getLabel()),
'genderTranslation' => $gender->getGenderTranslation(),
];
}
}

View File

@ -0,0 +1,68 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Serializer\Normalizer;
use Chill\MainBundle\Entity\Gender;
use Chill\MainBundle\Entity\GenderEnum;
use Chill\MainBundle\Serializer\Normalizer\GenderDocGenNormalizer;
use Chill\MainBundle\Templating\TranslatableStringHelperInterface;
use PHPUnit\Framework\TestCase;
/**
* @internal
*
* @coversNothing
*/
final class GenderDocGenNormalizerTest extends TestCase
{
private GenderDocGenNormalizer $normalizer;
private TranslatableStringHelperInterface $translatableStringHelper;
protected function setUp(): void
{
$this->translatableStringHelper = $this->createMock(TranslatableStringHelperInterface::class);
$this->normalizer = new GenderDocGenNormalizer($this->translatableStringHelper);
}
public function testSupportsNormalizationReturnsTrueForGenderInstance(): void
{
$gender = $this->createMock(Gender::class);
$this->assertTrue($this->normalizer->supportsNormalization($gender));
}
public function testSupportsNormalizationReturnsFalseForNonGenderInstance(): void
{
$this->assertFalse($this->normalizer->supportsNormalization(new \stdClass()));
}
public function testNormalizeReturnsCorrectData(): void
{
$gender = $this->createMock(Gender::class);
$gender->method('getId')->willReturn(1);
$gender->method('getLabel')->willReturn(['fr' => 'homme', 'en' => 'man']);
$gender->method('getGenderTranslation')->willReturn(GenderEnum::MALE);
$this->translatableStringHelper
->method('localize')
->with(['fr' => 'homme', 'en' => 'man'])
->willReturn('homme');
$expected = [
'id' => 1,
'label' => 'homme',
'genderTranslation' => GenderEnum::MALE,
];
$this->assertEquals($expected, $this->normalizer->normalize($gender));
}
}

View File

@ -48,12 +48,12 @@ class LoadAccompanyingPeriodClosingMotive extends AbstractFixture implements Ord
public static $references = []; public static $references = [];
public function getOrder() public function getOrder(): int
{ {
return 9500; return 9500;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (static::$closingMotives as $ref => $new) { foreach (static::$closingMotives as $ref => $new) {
$motive = new ClosingMotive(); $motive = new ClosingMotive();

View File

@ -38,7 +38,7 @@ class LoadAccompanyingPeriodNotifications extends AbstractFixture implements Dep
], ],
]; ];
public function getDependencies() public function getDependencies(): array
{ {
return [ return [
LoadPeople::class, LoadPeople::class,

View File

@ -27,12 +27,12 @@ class LoadAccompanyingPeriodOrigin extends AbstractFixture implements OrderedFix
private array $phoneCall = ['en' => 'phone call', 'fr' => 'appel téléphonique']; private array $phoneCall = ['en' => 'phone call', 'fr' => 'appel téléphonique'];
public function getOrder() public function getOrder(): int
{ {
return 9000; return 9000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$o = new Origin(); $o = new Origin();
$o->setLabel($this->phoneCall); $o->setLabel($this->phoneCall);

View File

@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle\DataFixtures\ORM; namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\AccompanyingPeriod; use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Entity\SocialWork\Evaluation; use Chill\PersonBundle\Entity\SocialWork\Evaluation;
use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\PersonBundle\Entity\SocialWork\SocialAction;
@ -28,14 +29,14 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
public function __construct(private readonly AccompanyingPeriodRepository $periodRepository, private readonly EvaluationRepository $evaluationRepository) {} public function __construct(private readonly AccompanyingPeriodRepository $periodRepository, private readonly EvaluationRepository $evaluationRepository) {}
public function getDependencies() public function getDependencies(): array
{ {
return [ return [
LoadPeople::class, LoadPeople::class,
]; ];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
// load all the period which are confirmed // load all the period which are confirmed
$periods = $this->periodRepository $periods = $this->periodRepository
@ -64,9 +65,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
->setStartDate(new \DateTimeImmutable('today')) ->setStartDate(new \DateTimeImmutable('today'))
->addPerson($period->getPersons()->first()) ->addPerson($period->getPersons()->first())
->setCreatedAt(new \DateTimeImmutable()) ->setCreatedAt(new \DateTimeImmutable())
->setCreatedBy($this->getReference('center a_social')) ->setCreatedBy($this->getReference('center a_social', User::class))
->setUpdatedAt(new \DateTimeImmutable()) ->setUpdatedAt(new \DateTimeImmutable())
->setUpdatedBy($this->getReference('center a_social')); ->setUpdatedBy($this->getReference('center a_social', User::class));
$manager->persist($work); $manager->persist($work);
if ($action->getEvaluations()->count() > 0) { if ($action->getEvaluations()->count() > 0) {
@ -91,9 +92,9 @@ class LoadAccompanyingPeriodWork extends \Doctrine\Bundle\FixturesBundle\Fixture
->setStartDate(new \DateTimeImmutable('today')) ->setStartDate(new \DateTimeImmutable('today'))
->addPerson($period->getPersons()->first()) ->addPerson($period->getPersons()->first())
->setCreatedAt(new \DateTimeImmutable()) ->setCreatedAt(new \DateTimeImmutable())
->setCreatedBy($this->getReference('center a_social')) ->setCreatedBy($this->getReference('center a_social', User::class))
->setUpdatedAt(new \DateTimeImmutable()) ->setUpdatedAt(new \DateTimeImmutable())
->setUpdatedBy($this->getReference('center a_social')); ->setUpdatedBy($this->getReference('center a_social', User::class));
$manager->persist($work); $manager->persist($work);
$ev = new AccompanyingPeriod\AccompanyingPeriodWorkEvaluation(); $ev = new AccompanyingPeriod\AccompanyingPeriodWorkEvaluation();
$ev->setAccompanyingPeriodWork($work) $ev->setAccompanyingPeriodWork($work)

View File

@ -40,12 +40,12 @@ class LoadCustomFields extends AbstractFixture implements OrderedFixtureInterfac
) {} ) {}
// put your code here // put your code here
public function getOrder() public function getOrder(): int
{ {
return 10003; return 10003;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$this->loadFields($manager); $this->loadFields($manager);
$this->loadData($manager); $this->loadData($manager);

View File

@ -16,6 +16,7 @@ use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\PostalCode;
use Chill\PersonBundle\Entity\Household\Household; use Chill\PersonBundle\Entity\Household\Household;
use Chill\PersonBundle\Entity\Household\Position;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\PersonBundle\Entity\Person\PersonCenterHistory; use Chill\PersonBundle\Entity\Person\PersonCenterHistory;
use Chill\PersonBundle\Household\MembersEditorFactory; use Chill\PersonBundle\Household\MembersEditorFactory;
@ -38,7 +39,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
$this->loader = new NativeLoader(); $this->loader = new NativeLoader();
} }
public function getDependencies() public function getDependencies(): array
{ {
return [ return [
LoadPeople::class, LoadPeople::class,
@ -46,7 +47,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
]; ];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
// generate two times the participation. This will lead to // generate two times the participation. This will lead to
// some movement in participation (same people in two differents // some movement in participation (same people in two differents
@ -127,7 +128,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
foreach ($this->getRandomPersons(1, 3) as $person) { foreach ($this->getRandomPersons(1, 3) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W')); $date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
$position = $this->getReference(LoadHouseholdPosition::ADULT); $position = $this->getReference(LoadHouseholdPosition::ADULT, Position::class);
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated'); $movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k; ++$k;
@ -136,7 +137,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
// load children // load children
foreach ($this->getRandomPersons(0, 3) as $person) { foreach ($this->getRandomPersons(0, 3) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W')); $date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
$position = $this->getReference(LoadHouseholdPosition::CHILD); $position = $this->getReference(LoadHouseholdPosition::CHILD, Position::class);
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated'); $movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k; ++$k;
@ -145,7 +146,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
// load children out // load children out
foreach ($this->getRandomPersons(0, 2) as $person) { foreach ($this->getRandomPersons(0, 2) as $person) {
$date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W')); $date = $startDate->add(new \DateInterval('P'.\random_int(1, 200).'W'));
$position = $this->getReference(LoadHouseholdPosition::CHILD_OUT); $position = $this->getReference(LoadHouseholdPosition::CHILD_OUT, Position::class);
$movement->addMovement($date, $person, $position, 0 === $k, 'self generated'); $movement->addMovement($date, $person, $position, 0 === $k, 'self generated');
++$k; ++$k;
@ -161,7 +162,7 @@ class LoadHousehold extends Fixture implements DependentFixtureInterface
{ {
$ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)]; $ref = LoadPostalCodes::$refs[\array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref); return $this->getReference($ref, PostalCode::class);
} }
private function getRandomPersons(int $min, int $max): array private function getRandomPersons(int $min, int $max): array

View File

@ -34,7 +34,7 @@ class LoadHouseholdCompositionType extends AbstractFixture implements FixtureGro
return ['composition-type']; return ['composition-type'];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (self::TYPES as $type) { foreach (self::TYPES as $type) {
$manager->persist( $manager->persist(

View File

@ -29,7 +29,7 @@ class LoadHouseholdPosition extends Fixture
['Enfant hors ménage', false, false, 3.0, self::CHILD_OUT], ['Enfant hors ménage', false, false, 3.0, self::CHILD_OUT],
]; ];
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach ( foreach (
self::POSITIONS_DATA as [$name, $share, $allowHolder, self::POSITIONS_DATA as [$name, $share, $allowHolder,

View File

@ -31,12 +31,12 @@ class LoadMaritalStatus extends AbstractFixture implements OrderedFixtureInterfa
['id' => 'unknown', 'name' => ['en' => 'unknown', 'fr' => 'indéterminé']], ['id' => 'unknown', 'name' => ['en' => 'unknown', 'fr' => 'indéterminé']],
]; ];
public function getOrder() public function getOrder(): int
{ {
return 9999; return 9999;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "loading maritalStatuses... \n"; echo "loading maritalStatuses... \n";

View File

@ -241,7 +241,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
$this->loader = new NativeLoader($this->faker); $this->loader = new NativeLoader($this->faker);
} }
public function getOrder() public function getOrder(): int
{ {
return 10000; return 10000;
} }
@ -310,7 +310,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
return $this->cacheMaritalStatuses[array_rand($this->cacheMaritalStatuses)]; return $this->cacheMaritalStatuses[array_rand($this->cacheMaritalStatuses)];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$this->loadExpectedPeople($manager); $this->loadExpectedPeople($manager);
$this->loadRandPeople($manager); $this->loadRandPeople($manager);
@ -358,8 +358,8 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
if (\random_int(0, 10) > 3) { if (\random_int(0, 10) > 3) {
// always add social scope: // always add social scope:
$accompanyingPeriod->addScope($this->getReference('scope_social')); $accompanyingPeriod->addScope($this->getReference('scope_social', Scope::class));
$origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN); $origin = $this->getReference(LoadAccompanyingPeriodOrigin::ACCOMPANYING_PERIOD_ORIGIN, AccompanyingPeriod\Origin::class);
$accompanyingPeriod->setOrigin($origin); $accompanyingPeriod->setOrigin($origin);
$accompanyingPeriod->setIntensity('regular'); $accompanyingPeriod->setIntensity('regular');
$accompanyingPeriod->setAddressLocation($this->createAddress()); $accompanyingPeriod->setAddressLocation($this->createAddress());
@ -472,7 +472,7 @@ class LoadPeople extends AbstractFixture implements ContainerAwareInterface, Ord
{ {
$ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]; $ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref); return $this->getReference($ref, PostalCode::class);
} }
private function getRandomSocialIssue(): SocialIssue private function getRandomSocialIssue(): SocialIssue

View File

@ -12,7 +12,9 @@ declare(strict_types=1);
namespace Chill\PersonBundle\DataFixtures\ORM; namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter; use Chill\PersonBundle\Security\Authorization\AccompanyingPeriodVoter;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
@ -25,16 +27,16 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface class LoadPersonACL extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 9600; return 9600;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
$scopeSocial = $this->getReference('scope_social'); $scopeSocial = $this->getReference('scope_social', Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {

View File

@ -35,7 +35,7 @@ class LoadRelations extends Fixture implements FixtureGroupInterface
return ['person_relations']; return ['person_relations'];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (self::RELATIONS as $key => $value) { foreach (self::RELATIONS as $key => $value) {
echo 'Creating a new relation type: relation'.$value['title']['fr'].'reverse relation: '.$value['reverseTitle']['fr']."\n"; echo 'Creating a new relation type: relation'.$value['title']['fr'].'reverse relation: '.$value['reverseTitle']['fr']."\n";

View File

@ -14,6 +14,7 @@ namespace Chill\PersonBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper; use Chill\PersonBundle\DataFixtures\Helper\PersonRandomHelper;
use Chill\PersonBundle\Entity\Relationships\Relation;
use Chill\PersonBundle\Entity\Relationships\Relationship; use Chill\PersonBundle\Entity\Relationships\Relationship;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
use Doctrine\Common\DataFixtures\DependentFixtureInterface; use Doctrine\Common\DataFixtures\DependentFixtureInterface;
@ -46,7 +47,7 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
->setFromPerson($this->getRandomPerson($this->em)) ->setFromPerson($this->getRandomPerson($this->em))
->setToPerson($this->getRandomPerson($this->em)) ->setToPerson($this->getRandomPerson($this->em))
->setRelation($this->getReference(LoadRelations::RELATION_KEY. ->setRelation($this->getReference(LoadRelations::RELATION_KEY.
random_int(0, \count(LoadRelations::RELATIONS) - 1))) random_int(0, \count(LoadRelations::RELATIONS) - 1), Relation::class))
->setReverse((bool) random_int(0, 1)) ->setReverse((bool) random_int(0, 1))
->setCreatedBy($user) ->setCreatedBy($user)
->setUpdatedBy($user) ->setUpdatedBy($user)
@ -74,6 +75,6 @@ class LoadRelationships extends Fixture implements DependentFixtureInterface
{ {
$userRef = array_rand(LoadUsers::$refs); $userRef = array_rand(LoadUsers::$refs);
return $this->getReference($userRef); return $this->getReference($userRef, User::class);
} }
} }

View File

@ -21,12 +21,12 @@ class LoadSocialWorkMetadata extends Fixture implements OrderedFixtureInterface
{ {
public function __construct(private readonly SocialWorkMetadata $importer) {} public function __construct(private readonly SocialWorkMetadata $importer) {}
public function getOrder() public function getOrder(): int
{ {
return 9500; return 9500;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
try { try {
$csv = Reader::createFromPath(__DIR__.'/data/social_work_metadata.csv'); $csv = Reader::createFromPath(__DIR__.'/data/social_work_metadata.csv');

View File

@ -169,7 +169,7 @@ class PersonSearch extends AbstractSearch implements HasAdvancedSearchFormInterf
* *
* @see \Chill\MainBundle\Search\SearchInterface::getOrder() * @see \Chill\MainBundle\Search\SearchInterface::getOrder()
*/ */
public function getOrder() public function getOrder(): int
{ {
return 100; return 100;
} }

View File

@ -0,0 +1,39 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Serializer\Normalizer;
use Chill\MainBundle\Entity\Gender;
use Chill\MainBundle\Templating\TranslatableStringHelper;
use Symfony\Component\Serializer\Normalizer\ContextAwareNormalizerInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareInterface;
use Symfony\Component\Serializer\Normalizer\NormalizerAwareTrait;
class GenderDocGenNormalizer implements ContextAwareNormalizerInterface, NormalizerAwareInterface
{
use NormalizerAwareTrait;
public function __construct(private readonly TranslatableStringHelper $translatableStringHelper) {}
public function supportsNormalization($data, ?string $format = null, array $context = [])
{
return $data instanceof Gender;
}
public function normalize($gender, ?string $format = null, array $context = [])
{
return [
'id' => $gender->getId(),
'label' => $this->translatableStringHelper->localize($gender->getLabel()),
'genderTranslation' => $gender->getGenderTranslation(),
];
}
}

View File

@ -95,7 +95,8 @@ class PersonDocGenNormalizer implements
'age' => (int) $person->getAge(), 'age' => (int) $person->getAge(),
'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext), 'birthdate' => $this->normalizer->normalize($person->getBirthdate(), $format, $dateContext),
'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext), 'deathdate' => $this->normalizer->normalize($person->getDeathdate(), $format, $dateContext),
'gender' => $this->normalizer->normalize($person->getGender(), $format, $genderContext), 'gender' => null !== ($g = $person->getGender()) ? $this->translatableStringHelper->localize($g->getLabel()) : '',
'genderEntity' => $this->normalizer->normalize($person->getGender(), $format, $genderContext),
'maritalStatus' => null !== ($ms = $person->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '', 'maritalStatus' => null !== ($ms = $person->getMaritalStatus()) ? $this->translatableStringHelper->localize($ms->getName()) : '',
'maritalStatusDate' => $this->normalizer->normalize($person->getMaritalStatusDate(), $format, $dateContext), 'maritalStatusDate' => $this->normalizer->normalize($person->getMaritalStatusDate(), $format, $dateContext),
'maritalStatusComment' => $this->normalizer->normalize($person->getMaritalStatusComment(), $format, $dateContext), 'maritalStatusComment' => $this->normalizer->normalize($person->getMaritalStatusComment(), $format, $dateContext),
@ -215,6 +216,7 @@ class PersonDocGenNormalizer implements
'civility' => Civility::class, 'civility' => Civility::class,
'birthdate' => \DateTimeInterface::class, 'birthdate' => \DateTimeInterface::class,
'deathdate' => \DateTimeInterface::class, 'deathdate' => \DateTimeInterface::class,
'genderEntity' => Gender::class,
'gender', 'maritalStatus', 'gender', 'maritalStatus',
'maritalStatusDate' => \DateTimeInterface::class, 'maritalStatusDate' => \DateTimeInterface::class,
'maritalStatusComment', 'maritalStatusComment',

View File

@ -40,7 +40,6 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
private const BLANK = [ private const BLANK = [
'id' => '', 'id' => '',
'center' => '',
'firstName' => '', 'firstName' => '',
'lastName' => '', 'lastName' => '',
'altNames' => '', 'altNames' => '',
@ -50,6 +49,7 @@ final class PersonDocGenNormalizerTest extends KernelTestCase
'birthdate' => ['short' => '', 'long' => ''], 'birthdate' => ['short' => '', 'long' => ''],
'deathdate' => ['short' => '', 'long' => ''], 'deathdate' => ['short' => '', 'long' => ''],
'gender' => '', 'gender' => '',
'genderEntity' => '',
'civility' => '@ignored', 'civility' => '@ignored',
'address' => '@ignored', 'address' => '@ignored',
'maritalStatus' => '', 'maritalStatus' => '',

View File

@ -12,6 +12,7 @@ declare(strict_types=1);
namespace Chill\ReportBundle\DataFixtures\ORM; namespace Chill\ReportBundle\DataFixtures\ORM;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -21,12 +22,12 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 15001; return 15001;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$cFTypes = [ $cFTypes = [
['type' => 'text', 'options' => ['maxLength' => '255']], ['type' => 'text', 'options' => ['maxLength' => '255']],
@ -74,7 +75,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
->setOptions($cFType['options']) ->setOptions($cFType['options'])
->setName(['fr' => "CustomField {$i}"]) ->setName(['fr' => "CustomField {$i}"])
->setOrdering(random_int(0, 1000) / 1000) ->setOrdering(random_int(0, 1000) / 1000)
->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3))); ->setCustomFieldsGroup($this->getReference('cf_group_report_'.random_int(0, 3), CustomFieldsGroup::class));
$manager->persist($customField); $manager->persist($customField);
} }
@ -87,7 +88,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
private function createExpectedFields(ObjectManager $manager) private function createExpectedFields(ObjectManager $manager)
{ {
// report logement // report logement
$reportLogement = $this->getReference('cf_group_report_logement'); $reportLogement = $this->getReference('cf_group_report_logement', CustomFieldsGroup::class);
$houseTitle = (new CustomField()) $houseTitle = (new CustomField())
->setSlug('house_title') ->setSlug('house_title')
@ -143,7 +144,7 @@ class LoadCustomField extends AbstractFixture implements OrderedFixtureInterface
$manager->persist($descriptionLogement); $manager->persist($descriptionLogement);
// report problems // report problems
$reportEducation = $this->getReference('cf_group_report_education'); $reportEducation = $this->getReference('cf_group_report_education', CustomFieldsGroup::class);
$title = (new CustomField()) $title = (new CustomField())
->setSlug('title') ->setSlug('title')

View File

@ -21,12 +21,12 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInterface class LoadCustomFieldsGroup extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 15000; return 15000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
echo "loading customFieldsGroup...\n"; echo "loading customFieldsGroup...\n";

View File

@ -13,7 +13,9 @@ namespace Chill\ReportBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
@ -24,19 +26,19 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface class LoadReportACL extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 14999; return 14999;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
printf("processing permission group %s \n", $permissionsGroup->getName()); printf("processing permission group %s \n", $permissionsGroup->getName());
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef); $scope = $this->getReference($scopeRef, Scope::class);
printf("processing scope %s \n", $scope->getName()['en']); printf("processing scope %s \n", $scope->getName()['en']);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {

View File

@ -12,8 +12,11 @@ declare(strict_types=1);
namespace Chill\ReportBundle\DataFixtures\ORM; namespace Chill\ReportBundle\DataFixtures\ORM;
use Chill\CustomFieldsBundle\Entity\CustomField; use Chill\CustomFieldsBundle\Entity\CustomField;
use Chill\CustomFieldsBundle\Entity\CustomFieldsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\DataFixtures\ORM\LoadUsers; use Chill\MainBundle\DataFixtures\ORM\LoadUsers;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
use Chill\PersonBundle\Entity\Person; use Chill\PersonBundle\Entity\Person;
use Chill\ReportBundle\Entity\Report; use Chill\ReportBundle\Entity\Report;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
@ -35,12 +38,12 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
$this->faker = FakerFactory::create('fr_FR'); $this->faker = FakerFactory::create('fr_FR');
} }
public function getOrder() public function getOrder(): int
{ {
return 15002; return 15002;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$this->createExpected($manager); $this->createExpected($manager);
@ -60,9 +63,9 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
if (null !== $charline) { if (null !== $charline) {
$report = (new Report()) $report = (new Report())
->setPerson($charline) ->setPerson($charline)
->setCFGroup($this->getReference('cf_group_report_logement')) ->setCFGroup($this->getReference('cf_group_report_logement', CustomFieldsGroup::class))
->setDate(new \DateTime('2015-01-05')) ->setDate(new \DateTime('2015-01-05'))
->setScope($this->getReference('scope_social')); ->setScope($this->getReference('scope_social', Scope::class));
$this->fillReport($report); $this->fillReport($report);
$manager->persist($report); $manager->persist($report);
@ -81,8 +84,8 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
->setPerson($person) ->setPerson($person)
->setCFGroup( ->setCFGroup(
random_int(0, 10) > 5 ? random_int(0, 10) > 5 ?
$this->getReference('cf_group_report_logement') : $this->getReference('cf_group_report_logement', CustomFieldsGroup::class) :
$this->getReference('cf_group_report_education') $this->getReference('cf_group_report_education', CustomFieldsGroup::class)
) )
->setScope($this->getScopeRandom()); ->setScope($this->getScopeRandom());
$this->fillReport($report); $this->fillReport($report);
@ -95,7 +98,7 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
// setUser // setUser
$usernameRef = array_rand(LoadUsers::$refs); $usernameRef = array_rand(LoadUsers::$refs);
$report->setUser( $report->setUser(
$this->getReference($usernameRef) $this->getReference($usernameRef, User::class)
); );
// set date if null // set date if null
@ -208,13 +211,13 @@ final class LoadReports extends AbstractFixture implements OrderedFixtureInterfa
} }
/** /**
* @return \Chill\MainBundle\Entity\Scope * @return Scope
*/ */
private function getScopeRandom() private function getScopeRandom()
{ {
$ref = LoadScopes::$references[array_rand(LoadScopes::$references)]; $ref = LoadScopes::$references[array_rand(LoadScopes::$references)];
return $this->getReference($ref); return $this->getReference($ref, Scope::class);
} }
/** /**

View File

@ -13,7 +13,9 @@ namespace Chill\TaskBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup; use Chill\MainBundle\DataFixtures\ORM\LoadPermissionsGroup;
use Chill\MainBundle\DataFixtures\ORM\LoadScopes; use Chill\MainBundle\DataFixtures\ORM\LoadScopes;
use Chill\MainBundle\Entity\PermissionsGroup;
use Chill\MainBundle\Entity\RoleScope; use Chill\MainBundle\Entity\RoleScope;
use Chill\MainBundle\Entity\Scope;
use Chill\TaskBundle\Security\Authorization\TaskVoter; use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Doctrine\Common\DataFixtures\AbstractFixture; use Doctrine\Common\DataFixtures\AbstractFixture;
use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Common\DataFixtures\OrderedFixtureInterface;
@ -25,18 +27,18 @@ use Doctrine\Persistence\ObjectManager;
*/ */
class LoadTaskACL extends AbstractFixture implements OrderedFixtureInterface class LoadTaskACL extends AbstractFixture implements OrderedFixtureInterface
{ {
public function getOrder() public function getOrder(): int
{ {
return 16000; return 16000;
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) { foreach (LoadPermissionsGroup::$refs as $permissionsGroupRef) {
$permissionsGroup = $this->getReference($permissionsGroupRef); $permissionsGroup = $this->getReference($permissionsGroupRef, PermissionsGroup::class);
foreach (LoadScopes::$references as $scopeRef) { foreach (LoadScopes::$references as $scopeRef) {
$scope = $this->getReference($scopeRef); $scope = $this->getReference($scopeRef, Scope::class);
// create permission group // create permission group
switch ($permissionsGroup->getName()) { switch ($permissionsGroup->getName()) {
case 'social': case 'social':

View File

@ -14,6 +14,7 @@ namespace Chill\ThirdPartyBundle\DataFixtures\ORM;
use Chill\MainBundle\DataFixtures\ORM\LoadCenters; use Chill\MainBundle\DataFixtures\ORM\LoadCenters;
use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes; use Chill\MainBundle\DataFixtures\ORM\LoadPostalCodes;
use Chill\MainBundle\Entity\Address; use Chill\MainBundle\Entity\Address;
use Chill\MainBundle\Entity\Center;
use Chill\MainBundle\Entity\PostalCode; use Chill\MainBundle\Entity\PostalCode;
use Chill\ThirdPartyBundle\Entity\ThirdParty; use Chill\ThirdPartyBundle\Entity\ThirdParty;
use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Bundle\FixturesBundle\Fixture;
@ -32,7 +33,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
$this->phoneNumberUtil = PhoneNumberUtil::getInstance(); $this->phoneNumberUtil = PhoneNumberUtil::getInstance();
} }
public function getDependencies() public function getDependencies(): array
{ {
return [ return [
LoadCenters::class, LoadCenters::class,
@ -40,7 +41,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
]; ];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$thirdParties = $this->getThirdParties()->getObjects(); $thirdParties = $this->getThirdParties()->getObjects();
@ -70,10 +71,10 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
$number = random_int(1, \count($references)); $number = random_int(1, \count($references));
if (1 === $number) { if (1 === $number) {
yield $this->getReference($references[array_rand($references)]); yield $this->getReference($references[array_rand($references)], Center::class);
} else { } else {
foreach (array_rand($references, $number) as $index) { foreach (array_rand($references, $number) as $index) {
yield $this->getReference($references[$index]); yield $this->getReference($references[$index], Center::class);
} }
} }
} }
@ -82,7 +83,7 @@ class LoadThirdParty extends Fixture implements DependentFixtureInterface
{ {
$ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)]; $ref = LoadPostalCodes::$refs[array_rand(LoadPostalCodes::$refs)];
return $this->getReference($ref); return $this->getReference($ref, PostalCode::class);
} }
private function getThirdParties(): ObjectSet private function getThirdParties(): ObjectSet

View File

@ -26,7 +26,7 @@ class LoadThirdPartyCategory extends Fixture implements FixtureGroupInterface
return ['thirdparty_categories']; return ['thirdparty_categories'];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$categories = [ $categories = [
['name' => ['fr' => 'maison médicale']], ['name' => ['fr' => 'maison médicale']],

View File

@ -26,7 +26,7 @@ class LoadThirdPartyProfession extends Fixture implements FixtureGroupInterface
return ['thirdparty_professions']; return ['thirdparty_professions'];
} }
public function load(ObjectManager $manager) public function load(ObjectManager $manager): void
{ {
$professions = [ $professions = [
['name' => ['fr' => 'Directeur']], ['name' => ['fr' => 'Directeur']],