mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-31 09:18:24 +00:00 
			
		
		
		
	Fixed: use CenterResolver where cases when center is resolved differently
This commit is contained in:
		| @@ -21,6 +21,9 @@ use Chill\ActivityBundle\Repository\ActivityTypeRepository; | ||||
| use Chill\ActivityBundle\Security\Authorization\ActivityVoter; | ||||
| use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; | ||||
| use Chill\MainBundle\Repository\LocationRepository; | ||||
| use Chill\MainBundle\Security\Resolver\CenterResolverDispatcher; | ||||
| use Chill\MainBundle\Security\Resolver\CenterResolverInterface; | ||||
| use Chill\MainBundle\Security\Resolver\CenterResolverManagerInterface; | ||||
| use Chill\PersonBundle\Entity\AccompanyingPeriod; | ||||
| use Chill\PersonBundle\Entity\Person; | ||||
| use Chill\PersonBundle\Privacy\PrivacyEvent; | ||||
| @@ -70,6 +73,8 @@ final class ActivityController extends AbstractController | ||||
|  | ||||
|     private ThirdPartyRepository $thirdPartyRepository; | ||||
|  | ||||
|     private CenterResolverManagerInterface $centerResolver; | ||||
|  | ||||
|     public function __construct( | ||||
|         ActivityACLAwareRepositoryInterface $activityACLAwareRepository, | ||||
|         ActivityTypeRepository $activityTypeRepository, | ||||
| @@ -82,7 +87,8 @@ final class ActivityController extends AbstractController | ||||
|         EntityManagerInterface $entityManager, | ||||
|         EventDispatcherInterface $eventDispatcher, | ||||
|         LoggerInterface $logger, | ||||
|         SerializerInterface $serializer | ||||
|         SerializerInterface $serializer, | ||||
|         CenterResolverManagerInterface $centerResolver | ||||
|     ) { | ||||
|         $this->activityACLAwareRepository = $activityACLAwareRepository; | ||||
|         $this->activityTypeRepository = $activityTypeRepository; | ||||
| @@ -96,6 +102,7 @@ final class ActivityController extends AbstractController | ||||
|         $this->eventDispatcher = $eventDispatcher; | ||||
|         $this->logger = $logger; | ||||
|         $this->serializer = $serializer; | ||||
|         $this->centerResolver = $centerResolver; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
| @@ -198,7 +205,7 @@ final class ActivityController extends AbstractController | ||||
|         // $this->denyAccessUnlessGranted('CHILL_ACTIVITY_UPDATE', $entity); | ||||
|  | ||||
|         $form = $this->createForm(ActivityType::class, $entity, [ | ||||
|             'center' => $entity->getCenters()[0] ?? null, | ||||
|             'center' => $this->centerResolver->resolveCenters($entity)[0] ?? null, | ||||
|             'role' => new Role('CHILL_ACTIVITY_UPDATE'), | ||||
|             'activityType' => $entity->getActivityType(), | ||||
|             'accompanyingPeriod' => $accompanyingPeriod, | ||||
| @@ -416,7 +423,7 @@ final class ActivityController extends AbstractController | ||||
|         $this->denyAccessUnlessGranted(ActivityVoter::CREATE, $entity); | ||||
|  | ||||
|         $form = $this->createForm(ActivityType::class, $entity, [ | ||||
|             'center' => $entity->getCenters()[0] ?? null, | ||||
|             'center' => $this->centerResolver->resolveCenters($entity)[0] ?? null, | ||||
|             'role' => new Role('CHILL_ACTIVITY_CREATE'), | ||||
|             'activityType' => $entity->getActivityType(), | ||||
|             'accompanyingPeriod' => $accompanyingPeriod, | ||||
|   | ||||
| @@ -306,14 +306,14 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac | ||||
|      * get the center | ||||
|      * center is extracted from person. | ||||
|      */ | ||||
|     public function getCenters(): array | ||||
|     public function getCenters(): iterable | ||||
|     { | ||||
|         if ($this->person instanceof Person) { | ||||
|             return [$this->person->getCenter()]; | ||||
|         } | ||||
|  | ||||
|         if ($this->getAccompanyingPeriod() instanceof AccompanyingPeriod) { | ||||
|             return $this->getAccompanyingPeriod()->getCenters(); | ||||
|             return $this->getAccompanyingPeriod()->getCenters() ?? []; | ||||
|         } | ||||
|  | ||||
|         return []; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user