mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
Pipeline fixes
This commit is contained in:
parent
4f170bf4cf
commit
73ccdd8b6e
@ -21,18 +21,14 @@ use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
|
||||
class CancelType extends AbstractType
|
||||
{
|
||||
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper)
|
||||
{
|
||||
}
|
||||
public function __construct(private readonly TranslatableStringHelperInterface $translatableStringHelper) {}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder->add('cancelReason', EntityType::class, [
|
||||
'class' => CancelReason::class,
|
||||
'required' => true,
|
||||
'choice_label' => function (CancelReason $cancelReason) {
|
||||
return $this->translatableStringHelper->localize($cancelReason->getName());
|
||||
},
|
||||
'choice_label' => fn (CancelReason $cancelReason) => $this->translatableStringHelper->localize($cancelReason->getName()),
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -21,6 +21,7 @@ namespace Chill\CalendarBundle\Messenger\Doctrine;
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarMessage;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRemovedMessage;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Event\PostRemoveEventArgs;
|
||||
use Doctrine\ORM\Event\PostUpdateEventArgs;
|
||||
@ -31,6 +32,17 @@ class CalendarEntityListener
|
||||
{
|
||||
public function __construct(private readonly MessageBusInterface $messageBus, private readonly Security $security) {}
|
||||
|
||||
private function getAuthenticatedUser(): User
|
||||
{
|
||||
$user = $this->security->getUser();
|
||||
|
||||
if (!$user instanceof User) {
|
||||
throw new \LogicException('Expected an instance of User.');
|
||||
}
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
public function postPersist(Calendar $calendar, PostPersistEventArgs $args): void
|
||||
{
|
||||
if (!$calendar->preventEnqueueChanges) {
|
||||
@ -38,7 +50,7 @@ class CalendarEntityListener
|
||||
new CalendarMessage(
|
||||
$calendar,
|
||||
CalendarMessage::CALENDAR_PERSIST,
|
||||
$this->security->getUser()
|
||||
$this->getAuthenticatedUser()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -50,7 +62,7 @@ class CalendarEntityListener
|
||||
$this->messageBus->dispatch(
|
||||
new CalendarRemovedMessage(
|
||||
$calendar,
|
||||
$this->security->getUser()
|
||||
$this->getAuthenticatedUser()
|
||||
)
|
||||
);
|
||||
}
|
||||
@ -62,17 +74,17 @@ class CalendarEntityListener
|
||||
$this->messageBus->dispatch(
|
||||
new CalendarRemovedMessage(
|
||||
$calendar,
|
||||
$this->security->getUser()
|
||||
$this->getAuthenticatedUser()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
if (!$calendar->preventEnqueueChanges && !$calendar->getStatus() === $calendar::STATUS_CANCELED) {
|
||||
if (!$calendar->preventEnqueueChanges) {
|
||||
$this->messageBus->dispatch(
|
||||
new CalendarMessage(
|
||||
$calendar,
|
||||
CalendarMessage::CALENDAR_UPDATE,
|
||||
$this->security->getUser()
|
||||
$this->getAuthenticatedUser()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user