From 0f635ca51a51dd9fa6bc88e40752a152f5670961 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 3 Jun 2021 20:13:49 +0200 Subject: [PATCH 1/4] SocialAction & Issues in Activity form --- .../Controller/ActivityController.php | 8 +-- .../ChillActivityBundle/Form/ActivityType.php | 41 +++++++++++++++- .../Resources/views/Activity/edit.html.twig | 8 ++- .../Resources/views/Activity/new.html.twig | 11 ++++- .../Entity/AccompanyingPeriod.php | 49 +++++++++++++------ 5 files changed, 94 insertions(+), 23 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 1dae24464..fd7bc2cf1 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -50,7 +50,7 @@ class ActivityController extends AbstractController protected AuthorizationHelper $authorizationHelper; protected LoggerInterface $logger; - + protected SerializerInterface $serializer; public function __construct( @@ -191,6 +191,7 @@ class ActivityController extends AbstractController 'center' => $entity->getCenter(), 'role' => new Role('CHILL_ACTIVITY_CREATE'), 'activityType' => $entity->getType(), + 'accompanyingPeriod' => $accompanyingPeriod, ])->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -210,7 +211,7 @@ class ActivityController extends AbstractController } $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); - + return $this->render($view, [ 'person' => $person, 'accompanyingCourse' => $accompanyingPeriod, @@ -294,6 +295,7 @@ class ActivityController extends AbstractController 'center' => $entity->getCenter(), 'role' => new Role('CHILL_ACTIVITY_UPDATE'), 'activityType' => $entity->getType(), + 'accompanyingPeriod' => $accompanyingPeriod, ])->handleRequest($request); if ($form->isSubmitted() && $form->isValid()) { @@ -324,7 +326,7 @@ class ActivityController extends AbstractController } $activity_array = $this->serializer->normalize($entity, 'json', ['groups' => 'read']); - + return $this->render($view, array( 'entity' => $entity, 'edit_form' => $form->createView(), diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index b8616eb53..8dd0cbc45 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -9,6 +9,8 @@ use Chill\DocStoreBundle\Form\StoredObjectType; use Chill\MainBundle\Form\Type\ChillCollectionType; use Chill\MainBundle\Form\Type\CommentType; use Chill\PersonBundle\Entity\Person; +use Chill\PersonBundle\Entity\SocialWork\SocialIssue; +use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Chill\ThirdPartyBundle\Entity\ThirdParty; use Doctrine\ORM\EntityRepository; use Symfony\Bridge\Doctrine\Form\Type\EntityType; @@ -94,6 +96,42 @@ class ActivityType extends AbstractType ]); } + /** @var ? \Chill\PersonBundle\Entity\AccompanyingPeriod $accompanyingPeriod */ + $accompanyingPeriod = NULL; + if ($options['accompanyingPeriod']) { + $accompanyingPeriod = $options['accompanyingPeriod']; + } + + if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) { + $builder->add('socialIssues', EntityType::class, [ + 'label' => $activityType->getLabel('socialIssues'), + 'required' => $activityType->isRequired('socialIssues'), + 'class' => SocialIssue::class, + 'choice_label' => function (SocialIssue $socialIssue) { + return $this->translatableStringHelper->localize($socialIssue->getTitle()); + }, + 'multiple' => true, + 'choices' => $accompanyingPeriod->getSocialIssues(), + ]); + } + + if($accompanyingPeriod) { + dump($accompanyingPeriod->getSocialActions()->toArray()); + } + + if ($activityType->isVisible('socialActions') && $accompanyingPeriod) { + $builder->add('socialActions', EntityType::class, [ + 'label' => $activityType->getLabel('socialActions'), + 'required' => $activityType->isRequired('socialActions'), + 'class' => SocialAction::class, + 'choice_label' => function (SocialAction $socialAction) { + return $this->translatableStringHelper->localize($socialAction->getTitle()); + }, + 'multiple' => true, + 'choices' => $accompanyingPeriod->getSocialActions(), + ]); + } + if ($activityType->isVisible('date')) { $builder->add('date', ChillDateType::class, [ 'label' => $activityType->getLabel('date'), @@ -313,10 +351,11 @@ class ActivityType extends AbstractType ]); $resolver - ->setRequired(['center', 'role', 'activityType']) + ->setRequired(['center', 'role', 'activityType', 'accompanyingPeriod']) ->setAllowedTypes('center', ['null', 'Chill\MainBundle\Entity\Center']) ->setAllowedTypes('role', 'Symfony\Component\Security\Core\Role\Role') ->setAllowedTypes('activityType', \Chill\ActivityBundle\Entity\ActivityType::class) + ->setAllowedTypes('accompanyingPeriod', [\Chill\PersonBundle\Entity\AccompanyingPeriod::class, 'null']) ; } diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig index d56af676e..0f6199f51 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/edit.html.twig @@ -19,7 +19,13 @@ {{ form_row(edit_form.scope) }} {% endif %} -.. type +{%- if form.socialActions is defined -%} + {{ form_row(form.socialActions) }} +{% endif %} + +{%- if form.socialIssues is defined -%} + {{ form_row(form.socialIssues) }} +{% endif %} {%- if edit_form.reasons is defined -%} {{ form_row(edit_form.reasons) }} diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig index c1f8b55b9..ead143415 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/new.html.twig @@ -20,9 +20,16 @@ {{ form_row(form.scope) }} {% endif %} -.. type +{%- if form.socialActions is defined -%} + {{ form_row(form.socialActions) }} +{% endif %} -{%- if form.reasons is defined -%} +{%- if form.socialIssues is defined -%} + {{ form_row(form.socialIssues) }} +{% endif %} + + +{%- if form.reasons is defined -%} {{ form_row(form.reasons) }} {% endif %} diff --git a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php index 9841a99f3..9a5b442c7 100644 --- a/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php +++ b/src/Bundle/ChillPersonBundle/Entity/AccompanyingPeriod.php @@ -53,36 +53,36 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface { /** * Mark an accompanying period as "occasional" - * + * * used in INTENSITY */ public const INTENSITY_OCCASIONAL = 'occasional'; - + /** * Mark an accompanying period as "regular" - * + * * used in INTENSITY */ public const INTENSITY_REGULAR = 'regular'; - + public const INTENSITIES = [self::INTENSITY_OCCASIONAL, self::INTENSITY_REGULAR]; - + /** * Mark an accompanying period as "draft". - * - * This means that the accompanying period is not yet + * + * This means that the accompanying period is not yet * confirmed by the creator */ public const STEP_DRAFT = 'DRAFT'; - + /** * Mark an accompanying period as "confirmed". - * - * This means that the accompanying period **is** + * + * This means that the accompanying period **is** * confirmed by the creator */ public const STEP_CONFIRMED = 'CONFIRMED'; - + /** * @var integer * @@ -176,7 +176,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface * @Groups({"read"}) */ private $step = self::STEP_DRAFT; - + /** * @ORM\ManyToOne(targetEntity=Origin::class) * @ORM\JoinColumn(nullable=true) @@ -274,7 +274,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface * ) */ private User $updatedBy; - + /** * @ORM\Column(type="datetime", nullable=true, options={"default": NULL}) */ @@ -416,7 +416,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface { if (NULL !== $this->initialComment) { $this->removeComment($this->initialComment); - } + } if ($comment instanceof Comment) { $this->addComment($comment); } @@ -473,7 +473,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface } /** - * Return true if the accompanying period contains a person. + * Return true if the accompanying period contains a person. * * **Note**: this participation can be opened or not. */ @@ -520,7 +520,7 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface return $participation; } - + /** * Remove Person @@ -823,6 +823,23 @@ class AccompanyingPeriod implements TrackCreationInterface, TrackUpdateInterface $this->socialIssues->removeElement($socialIssue); } + /** + * List of all the social actions of the accompanyingPeriod + * i.e. social actions From social issues from the accompanyingPeriod + */ + public function getSocialActions(): Collection + { + $ret = new ArrayCollection(); + + $this->socialIssues->forAll(function($key, $socialIssue) use ($ret) { + $socialIssue->getSocialActions()->forAll(function($key, $socialAction) use ($ret) { + $ret->add($socialAction); + }); + }); + + return $ret; + } + /** * Get a list of all persons which are participating to this course */ From 743d6cd0bfd027f3206f2ea137f0407b5919a2dd Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 3 Jun 2021 20:14:26 +0200 Subject: [PATCH 2/4] Method setX with return this (and not void) --- .../Entity/ActivityType.php | 140 +++++++++++++----- 1 file changed, 105 insertions(+), 35 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index 629b9187e..3446fa6dd 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -313,9 +313,11 @@ class ActivityType return $this->category; } - public function setCategory(?ActivityTypeCategory $category): void + public function setCategory(?ActivityTypeCategory $category): self { $this->category = $category; + + return $this; } public function getPersonVisible(): int @@ -323,9 +325,11 @@ class ActivityType return $this->personVisible; } - public function setPersonVisible(int $personVisible): void + public function setPersonVisible(int $personVisible): self { $this->personVisible = $personVisible; + + return $this; } public function getPersonLabel(): string @@ -333,9 +337,11 @@ class ActivityType return $this->personLabel; } - public function setPersonLabel(string $personLabel): void + public function setPersonLabel(string $personLabel): self { $this->personLabel = $personLabel; + + return $this; } public function getUserVisible(): int @@ -343,9 +349,11 @@ class ActivityType return $this->userVisible; } - public function setUserVisible(int $userVisible): void + public function setUserVisible(int $userVisible): self { $this->userVisible = $userVisible; + + return $this; } public function getUserLabel(): string @@ -353,9 +361,11 @@ class ActivityType return $this->userLabel; } - public function setUserLabel(string $userLabel): void + public function setUserLabel(string $userLabel): self { $this->userLabel = $userLabel; + + return $this; } public function getDateVisible(): int @@ -363,9 +373,11 @@ class ActivityType return $this->dateVisible; } - public function setDateVisible(int $dateVisible): void + public function setDateVisible(int $dateVisible): self { $this->dateVisible = $dateVisible; + + return $this; } public function getDateLabel(): string @@ -373,9 +385,11 @@ class ActivityType return $this->dateLabel; } - public function setDateLabel(string $dateLabel): void + public function setDateLabel(string $dateLabel): self { $this->dateLabel = $dateLabel; + + return $this; } public function getPlaceVisible(): int @@ -383,9 +397,11 @@ class ActivityType return $this->placeVisible; } - public function setPlaceVisible(int $placeVisible): void + public function setPlaceVisible(int $placeVisible): self { $this->placeVisible = $placeVisible; + + return $this; } public function getPlaceLabel(): string @@ -393,9 +409,11 @@ class ActivityType return $this->placeLabel; } - public function setPlaceLabel(string $placeLabel): void + public function setPlaceLabel(string $placeLabel): self { $this->placeLabel = $placeLabel; + + return $this; } public function getPersonsVisible(): int @@ -403,9 +421,11 @@ class ActivityType return $this->personsVisible; } - public function setPersonsVisible(int $personsVisible): void + public function setPersonsVisible(int $personsVisible): self { $this->personsVisible = $personsVisible; + + return $this; } public function getPersonsLabel(): string @@ -413,9 +433,11 @@ class ActivityType return $this->personsLabel; } - public function setPersonsLabel(string $personsLabel): void + public function setPersonsLabel(string $personsLabel): self { $this->personsLabel = $personsLabel; + + return $this; } public function getThirdPartiesVisible(): int @@ -423,9 +445,11 @@ class ActivityType return $this->thirdPartiesVisible; } - public function setThirdPartiesVisible(int $thirdPartiesVisible): void + public function setThirdPartiesVisible(int $thirdPartiesVisible): self { $this->thirdPartiesVisible = $thirdPartiesVisible; + + return $this; } public function getThirdPartiesLabel(): string @@ -433,9 +457,11 @@ class ActivityType return $this->thirdPartiesLabel; } - public function setThirdPartiesLabel(string $thirdPartiesLabel): void + public function setThirdPartiesLabel(string $thirdPartiesLabel): self { $this->thirdPartiesLabel = $thirdPartiesLabel; + + return $this; } public function getDurationTimeVisible(): int @@ -443,9 +469,11 @@ class ActivityType return $this->durationTimeVisible; } - public function setDurationTimeVisible(int $durationTimeVisible): void + public function setDurationTimeVisible(int $durationTimeVisible): self { $this->durationTimeVisible = $durationTimeVisible; + + return $this; } public function getDurationTimeLabel(): string @@ -453,9 +481,11 @@ class ActivityType return $this->durationTimeLabel; } - public function setDurationTimeLabel(string $durationTimeLabel): void + public function setDurationTimeLabel(string $durationTimeLabel): self { $this->durationTimeLabel = $durationTimeLabel; + + return $this; } public function getTravelTimeVisible(): int @@ -463,9 +493,11 @@ class ActivityType return $this->travelTimeVisible; } - public function setTravelTimeVisible(int $TravelTimeVisible): void + public function setTravelTimeVisible(int $TravelTimeVisible): self { $this->travelTimeVisible = $TravelTimeVisible; + + return $this; } public function getTravelTimeLabel(): string @@ -473,9 +505,11 @@ class ActivityType return $this->travelTimeLabel; } - public function setTravelTimeLabel(string $TravelTimeLabel): void + public function setTravelTimeLabel(string $TravelTimeLabel): self { $this->travelTimeLabel = $TravelTimeLabel; + + return $this; } public function getAttendeeVisible(): int @@ -483,9 +517,11 @@ class ActivityType return $this->attendeeVisible; } - public function setAttendeeVisible(int $attendeeVisible): void + public function setAttendeeVisible(int $attendeeVisible): self { $this->attendeeVisible = $attendeeVisible; + + return $this; } public function getAttendeeLabel(): string @@ -493,9 +529,11 @@ class ActivityType return $this->attendeeLabel; } - public function setAttendeeLabel(string $attendeeLabel): void + public function setAttendeeLabel(string $attendeeLabel): self { $this->attendeeLabel = $attendeeLabel; + + return $this; } public function getReasonsVisible(): int @@ -503,9 +541,11 @@ class ActivityType return $this->reasonsVisible; } - public function setReasonsVisible(int $reasonsVisible): void + public function setReasonsVisible(int $reasonsVisible): self { $this->reasonsVisible = $reasonsVisible; + + return $this; } public function getReasonsLabel(): string @@ -513,9 +553,11 @@ class ActivityType return $this->reasonsLabel; } - public function setReasonsLabel(string $reasonsLabel): void + public function setReasonsLabel(string $reasonsLabel): self { $this->reasonsLabel = $reasonsLabel; + + return $this; } public function getCommentVisible(): int @@ -523,9 +565,11 @@ class ActivityType return $this->commentVisible; } - public function setCommentVisible(int $commentVisible): void + public function setCommentVisible(int $commentVisible): self { $this->commentVisible = $commentVisible; + + return $this; } public function getCommentLabel(): string @@ -533,9 +577,11 @@ class ActivityType return $this->commentLabel; } - public function setCommentLabel(string $commentLabel): void + public function setCommentLabel(string $commentLabel): self { $this->commentLabel = $commentLabel; + + return $this; } public function getSentReceivedVisible(): int @@ -543,9 +589,11 @@ class ActivityType return $this->sentReceivedVisible; } - public function setSentReceivedVisible(int $sentReceivedVisible): void + public function setSentReceivedVisible(int $sentReceivedVisible): self { $this->sentReceivedVisible = $sentReceivedVisible; + + return $this; } public function getSentReceivedLabel(): string @@ -553,9 +601,11 @@ class ActivityType return $this->sentReceivedLabel; } - public function setSentReceivedLabel(string $sentReceivedLabel): void + public function setSentReceivedLabel(string $sentReceivedLabel): self { $this->sentReceivedLabel = $sentReceivedLabel; + + return $this; } public function getDocumentsVisible(): int @@ -563,9 +613,11 @@ class ActivityType return $this->documentsVisible; } - public function setDocumentsVisible(int $documentsVisible): void + public function setDocumentsVisible(int $documentsVisible): self { $this->documentsVisible = $documentsVisible; + + return $this; } public function getDocumentsLabel(): string @@ -573,9 +625,11 @@ class ActivityType return $this->documentsLabel; } - public function setDocumentsLabel(string $documentsLabel): void + public function setDocumentsLabel(string $documentsLabel): self { $this->documentsLabel = $documentsLabel; + + return $this; } public function getUsersVisible(): int @@ -583,9 +637,11 @@ class ActivityType return $this->usersVisible; } - public function setUsersVisible(int $usersVisible): void + public function setUsersVisible(int $usersVisible): self { $this->usersVisible = $usersVisible; + + return $this; } public function getUsersLabel(): string @@ -593,9 +649,11 @@ class ActivityType return $this->usersLabel; } - public function setUsersLabel(string $usersLabel): void + public function setUsersLabel(string $usersLabel): self { $this->usersLabel = $usersLabel; + + return $this; } public function getEmergencyVisible(): int @@ -603,9 +661,11 @@ class ActivityType return $this->emergencyVisible; } - public function setEmergencyVisible(int $emergencyVisible): void + public function setEmergencyVisible(int $emergencyVisible): self { $this->emergencyVisible = $emergencyVisible; + + return $this; } public function getEmergencyLabel(): string @@ -613,9 +673,11 @@ class ActivityType return $this->emergencyLabel; } - public function setEmergencyLabel(string $emergencyLabel): void + public function setEmergencyLabel(string $emergencyLabel): self { $this->emergencyLabel = $emergencyLabel; + + return $this; } public function getAccompanyingPeriodVisible(): int @@ -623,9 +685,11 @@ class ActivityType return $this->accompanyingPeriodVisible; } - public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): void + public function setAccompanyingPeriodVisible(int $accompanyingPeriodVisible): self { $this->accompanyingPeriodVisible = $accompanyingPeriodVisible; + + return $this; } public function getAccompanyingPeriodLabel(): string @@ -633,9 +697,11 @@ class ActivityType return $this->accompanyingPeriodLabel; } - public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): void + public function setAccompanyingPeriodLabel(string $accompanyingPeriodLabel): self { $this->accompanyingPeriodLabel = $accompanyingPeriodLabel; + + return $this; } public function getSocialDataVisible(): int @@ -643,9 +709,11 @@ class ActivityType return $this->socialDataVisible; } - public function setSocialDataVisible(int $socialDataVisible): void + public function setSocialDataVisible(int $socialDataVisible): self { $this->socialDataVisible = $socialDataVisible; + + return $this; } public function getSocialDataLabel(): string @@ -653,9 +721,11 @@ class ActivityType return $this->socialDataLabel; } - public function setSocialDataLabel(string $socialDataLabel): void + public function setSocialDataLabel(string $socialDataLabel): self { $this->socialDataLabel = $socialDataLabel; + + return $this; } public function isVisible(string $field): bool From 455305127123d7216db7e719549ba07fa014de6f Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 3 Jun 2021 20:15:13 +0200 Subject: [PATCH 3/4] Review load fixtures for activityType & categories --- .../DataFixtures/ORM/LoadActivityType.php | 61 +++++++++++----- .../ORM/LoadActivityTypeCategory.php | 72 +++++++++++++++++++ 2 files changed, 114 insertions(+), 19 deletions(-) create mode 100644 src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php index fa846df68..de3c1d4de 100644 --- a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityType.php @@ -2,27 +2,27 @@ /* * Chill is a software for social workers - * - * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, + * + * Copyright (C) 2014-2015, Champs Libres Cooperative SCRLFS, * , - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. - * + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. - * + * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ namespace Chill\ActivityBundle\DataFixtures\ORM; -use Doctrine\Common\DataFixtures\AbstractFixture; +use Doctrine\Bundle\FixturesBundle\Fixture; use Doctrine\Common\DataFixtures\OrderedFixtureInterface; use Doctrine\Persistence\ObjectManager; use Chill\ActivityBundle\Entity\ActivityType; @@ -32,36 +32,59 @@ use Chill\ActivityBundle\Entity\ActivityType; * * @author Champs-Libres Coop */ -class LoadActivityType extends AbstractFixture implements OrderedFixtureInterface +class LoadActivityType extends Fixture implements OrderedFixtureInterface { public function getOrder() { return 16100; } - + public static $references = array(); public function load(ObjectManager $manager) { $types = [ - [ 'name' => - ['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel']], - [ 'name' => - ['fr' => 'Entretien', 'en' => 'Interview', 'nl' => 'Vraaggesprek']], - [ 'name' => - ['fr' => 'Inspection', 'en' => 'Inspection', 'nl' => 'Inspectie']] + # Exange + [ + 'name' => + ['fr' => 'Entretien physique avec l\'usager'], + 'category' => 'exchange' ], + [ + 'name' => + ['fr' => 'Appel téléphonique', 'en' => 'Telephone call', 'nl' => 'Telefoon appel'], + 'category' => 'exchange' ], + [ + 'name' => + ['fr' => 'Courriel', 'en' => 'Email', 'nl' => 'Email'], + 'category' => 'exchange' ], + # Meeting + [ + 'name' => + ['fr' => 'Point technique encadrant'], + 'category' => 'meeting' ], + [ + 'name' => + ['fr' => 'Réunion avec des partenaires'], + 'category' => 'meeting' ], + [ + 'name' => + ['fr' => 'Commission pluridisciplinaire et pluri-institutionnelle'], + 'category' => 'meeting' ], ]; - + foreach ($types as $t) { - print "Creating activity type : " . $t['name']['en'] . "\n"; + print "Creating activity type : " . $t['name']['fr'] . " (cat:". $t['category'] . " \n"; $activityType = (new ActivityType()) - ->setName(($t['name'])); + ->setName(($t['name'])) + ->setCategory($this->getReference('activity_type_cat_'.$t['category'])) + ->setSocialIssuesVisible(1) + ->setSocialActionsVisible(1); $manager->persist($activityType); - $reference = 'activity_type_'.$t['name']['en']; + $reference = 'activity_type_'.$t['name']['fr']; $this->addReference($reference, $activityType); static::$references[] = $reference; } - + $manager->flush(); } } diff --git a/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php new file mode 100644 index 000000000..40e45fcf4 --- /dev/null +++ b/src/Bundle/ChillActivityBundle/DataFixtures/ORM/LoadActivityTypeCategory.php @@ -0,0 +1,72 @@ +, + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as + * published by the Free Software Foundation, either version 3 of the + * License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +namespace Chill\ActivityBundle\DataFixtures\ORM; + +use Doctrine\Bundle\FixturesBundle\Fixture; +use Doctrine\Common\DataFixtures\OrderedFixtureInterface; +use Doctrine\Persistence\ObjectManager; +use Chill\ActivityBundle\Entity\ActivityTypeCategory; + +/** + * Fixtures for ActivityTypeCategory + * + * @author Champs-Libres Coop + */ +class LoadActivityTypeCategory extends Fixture implements OrderedFixtureInterface +{ + public static $references = array(); + + public function getOrder() + { + return 16050; + } + + public function load(ObjectManager $manager) + { + $categories = [ + [ + 'name' => ['fr' => 'Échange avec usager', 'en' => 'Exchange with user'], + 'ref' => 'exchange', + ], + [ + 'name' => ['fr' => 'Réunion', 'en' => 'Meeting'], + 'ref' => 'meeting', + ], + ]; + + foreach ($categories as $cat) { + print "Creating activity type category : " . $cat['ref'] . "\n"; + + $newCat = (new ActivityTypeCategory()) + ->setName(($cat['name'])); + + $manager->persist($newCat); + $reference = 'activity_type_cat_'.$cat['ref']; + + $this->addReference($reference, $newCat); + static::$references[] = $reference; + } + + $manager->flush(); + } +} From 4a1ebc1c4c9f49d205df92e8632996498b36fdc7 Mon Sep 17 00:00:00 2001 From: Marc Ducobu Date: Thu, 3 Jun 2021 20:18:47 +0200 Subject: [PATCH 4/4] Removing dump --- src/Bundle/ChillActivityBundle/Form/ActivityType.php | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 8dd0cbc45..2e2c68812 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -115,10 +115,6 @@ class ActivityType extends AbstractType ]); } - if($accompanyingPeriod) { - dump($accompanyingPeriod->getSocialActions()->toArray()); - } - if ($activityType->isVisible('socialActions') && $accompanyingPeriod) { $builder->add('socialActions', EntityType::class, [ 'label' => $activityType->getLabel('socialActions'),