Resolve "Notification: envoi à des groupes utilisateurs"

This commit is contained in:
2025-07-20 20:18:49 +00:00
committed by Julien Fastré
parent 5bdb2df929
commit ab8da4ab7a
47 changed files with 1635 additions and 148 deletions

View File

@@ -16,6 +16,7 @@ use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Notification\NotificationPersisterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Event\Person\PersonAddressMoveEvent;
use Chill\PersonBundle\Notification\FlagProviders\PersonAddressMoveNotificationFlagProvider;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\Translation\TranslatorInterface;
@@ -65,7 +66,8 @@ class PersonAddressMoveEventSubscriber implements EventSubscriberInterface
->setMessage($this->engine->render('@ChillPerson/AccompanyingPeriod/notification_location_user_on_period_has_moved.fr.txt.twig', [
'oldPersonLocation' => $person,
'period' => $period,
]));
]))
->setType(PersonAddressMoveNotificationFlagProvider::FLAG);
$this->notificationPersister->persist($notification);
}

View File

@@ -15,6 +15,7 @@ use Chill\MainBundle\Entity\Notification;
use Chill\MainBundle\Entity\User;
use Chill\MainBundle\Notification\NotificationPersisterInterface;
use Chill\PersonBundle\Entity\AccompanyingPeriod;
use Chill\PersonBundle\Notification\FlagProviders\DesignatedReferrerNotificationFlagProvider;
use Doctrine\Persistence\Event\LifecycleEventArgs;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\Security\Core\Security;
@@ -73,7 +74,8 @@ class UserRefEventSubscriber implements EventSubscriberInterface
'accompanyingCourse' => $period,
]
))
->addAddressee($period->getUser());
->addAddressee($period->getUser())
->setType(DesignatedReferrerNotificationFlagProvider::FLAG);
$this->notificationPersister->persist($notification);
}

View File

@@ -11,6 +11,7 @@ declare(strict_types=1);
namespace Chill\PersonBundle;
use Chill\MainBundle\Notification\FlagProviders\NotificationFlagProviderInterface;
use Chill\PersonBundle\Actions\Remove\PersonMoveSqlHandlerInterface;
use Chill\PersonBundle\DependencyInjection\CompilerPass\AccompanyingPeriodTimelineCompilerPass;
use Chill\PersonBundle\Export\Helper\CustomizeListPersonHelperInterface;
@@ -35,5 +36,7 @@ class ChillPersonBundle extends Bundle
->addTag('chill_person.person_move_handler');
$container->registerForAutoconfiguration(CustomizeListPersonHelperInterface::class)
->addTag('chill_person.list_person_customizer');
$container->registerForAutoconfiguration(NotificationFlagProviderInterface::class)
->addTag('chill_main.notification_flag_provider');
}
}

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Notification\FlagProviders;
use Chill\MainBundle\Notification\FlagProviders\NotificationFlagProviderInterface;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
class DesignatedReferrerNotificationFlagProvider implements NotificationFlagProviderInterface
{
public const FLAG = 'referrer-acc-course-notif';
public function getFlag(): string
{
return self::FLAG;
}
public function getLabel(): TranslatableInterface
{
return new TranslatableMessage('notification.flags.referrer-acc-course');
}
}

View File

@@ -0,0 +1,31 @@
<?php
declare(strict_types=1);
/*
* Chill is a software for social workers
*
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/
namespace Chill\PersonBundle\Notification\FlagProviders;
use Chill\MainBundle\Notification\FlagProviders\NotificationFlagProviderInterface;
use Symfony\Component\Translation\TranslatableMessage;
use Symfony\Contracts\Translation\TranslatableInterface;
class PersonAddressMoveNotificationFlagProvider implements NotificationFlagProviderInterface
{
public const FLAG = 'person-move-notif';
public function getFlag(): string
{
return self::FLAG;
}
public function getLabel(): TranslatableInterface
{
return new TranslatableMessage('notification.flags.person-address-move');
}
}

View File

@@ -1,4 +1,8 @@
services:
_defaults:
autowire: true
autoconfigure: true
Chill\PersonBundle\Notification\AccompanyingPeriodNotificationHandler:
autowire: true
autoconfigure: true
@@ -8,3 +12,5 @@ services:
Chill\PersonBundle\Notification\AccompanyingPeriodWorkEvaluationDocumentNotificationHandler:
autowire: true
autoconfigure: true
Chill\PersonBundle\Notification\FlagProviders\DesignatedReferrerNotificationFlagProvider: ~
Chill\PersonBundle\Notification\FlagProviders\PersonAddressMoveNotificationFlagProvider: ~