mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-30 11:33:49 +00:00
Merge branch 'master' into 20-finalisation-cire
This commit is contained in:
@@ -113,9 +113,7 @@ class ParticipationController extends AbstractController
|
||||
[
|
||||
'event_id' => current($participations)->getEvent()->getId(),
|
||||
'persons_ids' => implode(',', array_map(
|
||||
static function (Participation $p) {
|
||||
return $p->getPerson()->getId();
|
||||
},
|
||||
static fn (Participation $p) => $p->getPerson()->getId(),
|
||||
$participations
|
||||
)),
|
||||
]
|
||||
@@ -649,19 +647,14 @@ class ParticipationController extends AbstractController
|
||||
|
||||
// create a collection of person's id participating to the event
|
||||
/** @var \Doctrine\Common\Collections\ArrayCollection $peopleParticipating */
|
||||
$peopleParticipating = $peopleParticipating ??
|
||||
$participation->getEvent()->getParticipations()->map(
|
||||
static function (Participation $p) {
|
||||
return $p->getPerson()->getId();
|
||||
}
|
||||
);
|
||||
$peopleParticipating ??= $participation->getEvent()->getParticipations()->map(
|
||||
static fn (Participation $p) => $p->getPerson()->getId()
|
||||
);
|
||||
// check that the user is not already in the event
|
||||
if ($peopleParticipating->contains($participation->getPerson()->getId())) {
|
||||
$ignoredParticipations[] = $participation
|
||||
->getEvent()->getParticipations()->filter(
|
||||
static function (Participation $p) use ($participation) {
|
||||
return $p->getPerson()->getId() === $participation->getPerson()->getId();
|
||||
}
|
||||
static fn (Participation $p) => $p->getPerson()->getId() === $participation->getPerson()->getId()
|
||||
)->first();
|
||||
} else {
|
||||
$newParticipations[] = $participation;
|
||||
|
@@ -43,7 +43,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
|
||||
for ($i = 0; $i < $expectedNumber; ++$i) {
|
||||
$event = (new Event())
|
||||
->setDate($this->faker->dateTimeBetween('-2 years', '+6 months'))
|
||||
->setName($this->faker->words(mt_rand(2, 4), true))
|
||||
->setName($this->faker->words(random_int(2, 4), true))
|
||||
->setType($this->getReference(LoadEventTypes::$refs[array_rand(LoadEventTypes::$refs)]))
|
||||
->setCenter($center)
|
||||
->setCircle(
|
||||
@@ -75,7 +75,7 @@ class LoadParticipation extends AbstractFixture implements OrderedFixtureInterfa
|
||||
|
||||
/** @var \Chill\PersonBundle\Entity\Person $person */
|
||||
foreach ($people as $person) {
|
||||
$nb = mt_rand(0, 3);
|
||||
$nb = random_int(0, 3);
|
||||
|
||||
for ($i = 0; $i < $nb; ++$i) {
|
||||
$event = $events[array_rand($events)];
|
||||
|
@@ -24,7 +24,7 @@ class Configuration implements ConfigurationInterface
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder('chill_event');
|
||||
$rootNode = $treeBuilder->getRootNode('chill_event');
|
||||
$rootNode = $treeBuilder->getRootNode();
|
||||
|
||||
// Here you should define the parameters that are allowed to
|
||||
// configure your bundle. See the documentation linked above for
|
||||
|
@@ -176,9 +176,7 @@ class Event implements HasCenterInterface, HasScopeInterface
|
||||
{
|
||||
$iterator = $this->participations->getIterator();
|
||||
|
||||
$iterator->uasort(static function ($first, $second) {
|
||||
return strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName());
|
||||
});
|
||||
$iterator->uasort(static fn ($first, $second) => strnatcasecmp($first->getPerson()->getFirstName(), $second->getPerson()->getFirstName()));
|
||||
|
||||
return $iterator;
|
||||
}
|
||||
|
@@ -62,9 +62,7 @@ class EventChoiceLoader implements ChoiceLoaderInterface
|
||||
{
|
||||
return new \Symfony\Component\Form\ChoiceList\ArrayChoiceList(
|
||||
$this->lazyLoadedEvents,
|
||||
static function (Event $p) use ($value) {
|
||||
return call_user_func($value, $p);
|
||||
}
|
||||
static fn (Event $p) => call_user_func($value, $p)
|
||||
);
|
||||
}
|
||||
|
||||
|
@@ -54,7 +54,7 @@ class EventType extends AbstractType
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Chill\EventBundle\Entity\Event',
|
||||
'data_class' => \Chill\EventBundle\Entity\Event::class,
|
||||
]);
|
||||
$resolver
|
||||
->setRequired(['center', 'role'])
|
||||
|
@@ -36,7 +36,7 @@ class EventTypeType extends AbstractType
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Chill\EventBundle\Entity\EventType',
|
||||
'data_class' => \Chill\EventBundle\Entity\EventType::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -38,9 +38,7 @@ class RoleType extends AbstractType
|
||||
->add('active')
|
||||
->add('type', EntityType::class, [
|
||||
'class' => EventType::class,
|
||||
'choice_label' => function (EventType $e) {
|
||||
return $this->translatableStringHelper->localize($e->getName());
|
||||
},
|
||||
'choice_label' => fn (EventType $e) => $this->translatableStringHelper->localize($e->getName()),
|
||||
]);
|
||||
}
|
||||
|
||||
@@ -55,7 +53,7 @@ class RoleType extends AbstractType
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Chill\EventBundle\Entity\Role',
|
||||
'data_class' => \Chill\EventBundle\Entity\Role::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -38,7 +38,7 @@ class StatusType extends AbstractType
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults([
|
||||
'data_class' => 'Chill\EventBundle\Entity\Status',
|
||||
'data_class' => \Chill\EventBundle\Entity\Status::class,
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
@@ -109,16 +109,12 @@ class PickEventType extends AbstractType
|
||||
// add the default options
|
||||
$resolver->setDefaults([
|
||||
'class' => Event::class,
|
||||
'choice_label' => static function (Event $e) {
|
||||
return $e->getDate()->format('d/m/Y, H:i') . ' → ' .
|
||||
// $e->getType()->getName()['fr'] . ': ' . // display the type of event
|
||||
$e->getName();
|
||||
},
|
||||
'choice_label' => static fn (Event $e) => $e->getDate()->format('d/m/Y, H:i') . ' → ' .
|
||||
// $e->getType()->getName()['fr'] . ': ' . // display the type of event
|
||||
$e->getName(),
|
||||
'placeholder' => 'Pick an event',
|
||||
'attr' => ['class' => 'select2 '],
|
||||
'choice_attr' => static function (Event $e) {
|
||||
return ['data-center' => $e->getCenter()->getId()];
|
||||
},
|
||||
'choice_attr' => static fn (Event $e) => ['data-center' => $e->getCenter()->getId()],
|
||||
'choiceloader' => function (Options $options) {
|
||||
$centers = $this->filterCenters($options);
|
||||
|
||||
@@ -143,9 +139,7 @@ class PickEventType extends AbstractType
|
||||
// option role
|
||||
if (null === $options['role']) {
|
||||
$centers = array_map(
|
||||
static function (GroupCenter $g) {
|
||||
return $g->getCenter();
|
||||
},
|
||||
static fn (GroupCenter $g) => $g->getCenter(),
|
||||
$this->user->getGroupCenters()->toArray()
|
||||
);
|
||||
} else {
|
||||
@@ -173,9 +167,7 @@ class PickEventType extends AbstractType
|
||||
|
||||
if (
|
||||
!in_array($c->getId(), array_map(
|
||||
static function (Center $c) {
|
||||
return $c->getId();
|
||||
},
|
||||
static fn (Center $c) => $c->getId(),
|
||||
$centers
|
||||
), true)
|
||||
) {
|
||||
|
@@ -39,16 +39,10 @@ class PickEventTypeType extends AbstractType
|
||||
$resolver->setDefaults(
|
||||
[
|
||||
'class' => EventType::class,
|
||||
'query_builder' => static function (EntityRepository $er) {
|
||||
return $er->createQueryBuilder('et')
|
||||
->where('et.active = true');
|
||||
},
|
||||
'choice_label' => static function (EventType $t) use ($helper) {
|
||||
return $helper->localize($t->getName());
|
||||
},
|
||||
'choice_attrs' => static function (EventType $t) {
|
||||
return ['data-link-category' => $t->getId()];
|
||||
},
|
||||
'query_builder' => static fn (EntityRepository $er) => $er->createQueryBuilder('et')
|
||||
->where('et.active = true'),
|
||||
'choice_label' => static fn (EventType $t) => $helper->localize($t->getName()),
|
||||
'choice_attrs' => static fn (EventType $t) => ['data-link-category' => $t->getId()],
|
||||
]
|
||||
);
|
||||
}
|
||||
|
@@ -80,9 +80,7 @@ class PickRoleType extends AbstractType
|
||||
$options = $config->getOptions();
|
||||
|
||||
$form->getParent()->add($name, $type, array_replace($options, [
|
||||
'group_by' => function (Role $r) {
|
||||
return $this->translatableStringHelper->localize($r->getType()->getName());
|
||||
},
|
||||
'group_by' => fn (Role $r) => $this->translatableStringHelper->localize($r->getType()->getName()),
|
||||
]));
|
||||
}
|
||||
}
|
||||
@@ -111,17 +109,13 @@ class PickRoleType extends AbstractType
|
||||
'class' => Role::class,
|
||||
'query_builder' => $qb,
|
||||
'group_by' => null,
|
||||
'choice_attr' => static function (Role $r) {
|
||||
return [
|
||||
'data-event-type' => $r->getType()->getId(),
|
||||
'data-link-category' => $r->getType()->getId(),
|
||||
];
|
||||
},
|
||||
'choice_label' => static function (Role $r) use ($translatableStringHelper, $translator) {
|
||||
return $translatableStringHelper->localize($r->getName()) .
|
||||
($r->getActive() === true ? '' :
|
||||
' (' . $translator->trans('unactive') . ')');
|
||||
},
|
||||
'choice_attr' => static fn (Role $r) => [
|
||||
'data-event-type' => $r->getType()->getId(),
|
||||
'data-link-category' => $r->getType()->getId(),
|
||||
],
|
||||
'choice_label' => static fn (Role $r) => $translatableStringHelper->localize($r->getName()) .
|
||||
($r->getActive() === true ? '' :
|
||||
' (' . $translator->trans('unactive') . ')'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -82,9 +82,7 @@ class PickStatusType extends AbstractType
|
||||
$type = $config->getType()->getName();
|
||||
$options = $config->getOptions();
|
||||
$form->getParent()->add($name, $type, array_replace($options, [
|
||||
'group_by' => function (Status $s) {
|
||||
return $this->translatableStringHelper->localize($s->getType()->getName());
|
||||
},
|
||||
'group_by' => fn (Status $s) => $this->translatableStringHelper->localize($s->getType()->getName()),
|
||||
]));
|
||||
}
|
||||
);
|
||||
@@ -112,17 +110,13 @@ class PickStatusType extends AbstractType
|
||||
'class' => Status::class,
|
||||
'query_builder' => $qb,
|
||||
'group_by' => null,
|
||||
'choice_attr' => static function (Status $s) {
|
||||
return [
|
||||
'data-event-type' => $s->getType()->getId(),
|
||||
'data-link-category' => $s->getType()->getId(),
|
||||
];
|
||||
},
|
||||
'choice_label' => static function (Status $s) use ($translatableStringHelper, $translator) {
|
||||
return $translatableStringHelper->localize($s->getName()) .
|
||||
($s->getActive() === true ? '' :
|
||||
' (' . $translator->trans('unactive') . ')');
|
||||
},
|
||||
'choice_attr' => static fn (Status $s) => [
|
||||
'data-event-type' => $s->getType()->getId(),
|
||||
'data-link-category' => $s->getType()->getId(),
|
||||
],
|
||||
'choice_label' => static fn (Status $s) => $translatableStringHelper->localize($s->getName()) .
|
||||
($s->getActive() === true ? '' :
|
||||
' (' . $translator->trans('unactive') . ')'),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@@ -239,9 +239,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$this->personsIdsCache = array_merge(
|
||||
$this->personsIdsCache,
|
||||
$event->getParticipations()->map(
|
||||
static function ($p) {
|
||||
return $p->getPerson()->getId();
|
||||
}
|
||||
static fn ($p) => $p->getPerson()->getId()
|
||||
)
|
||||
->toArray()
|
||||
);
|
||||
@@ -305,9 +303,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$event = $this->getRandomEventWithMultipleParticipations();
|
||||
|
||||
$persons_id = implode(',', $event->getParticipations()->map(
|
||||
static function ($p) {
|
||||
return $p->getPerson()->getId();
|
||||
}
|
||||
static fn ($p) => $p->getPerson()->getId()
|
||||
)->toArray());
|
||||
|
||||
$crawler = $this->client->request(
|
||||
@@ -333,9 +329,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
$nbParticipations = $event->getParticipations()->count();
|
||||
// get the persons_id participating on this event
|
||||
$persons_id = $event->getParticipations()->map(
|
||||
static function ($p) {
|
||||
return $p->getPerson()->getId();
|
||||
}
|
||||
static fn ($p) => $p->getPerson()->getId()
|
||||
)->toArray();
|
||||
// exclude the existing persons_ids from the new person
|
||||
$this->personsIdsCache = array_merge($this->personsIdsCache, $persons_id);
|
||||
@@ -464,9 +458,7 @@ final class ParticipationControllerTest extends WebTestCase
|
||||
|
||||
$circles = $this->em->getRepository(\Chill\MainBundle\Entity\Scope::class)
|
||||
->findAll();
|
||||
array_filter($circles, static function ($circle) use ($circleName) {
|
||||
return in_array($circleName, $circle->getName(), true);
|
||||
});
|
||||
array_filter($circles, static fn ($circle) => in_array($circleName, $circle->getName(), true));
|
||||
$circle = $circles[0];
|
||||
|
||||
$events = $this->em->getRepository(\Chill\EventBundle\Entity\Event::class)
|
||||
|
@@ -208,9 +208,7 @@ class TimelineEventProvider implements TimelineProviderInterface
|
||||
|
||||
foreach ($reachableCenters as $center) {
|
||||
$reachableCircleId = array_map(
|
||||
static function (Scope $scope) {
|
||||
return $scope->getId();
|
||||
},
|
||||
static fn (Scope $scope) => $scope->getId(),
|
||||
$this->helper->getReachableCircles($this->user, $role, $person->getCenter())
|
||||
);
|
||||
$centerAndScopeLines[] = sprintf(
|
||||
|
Reference in New Issue
Block a user