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