mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 22:53:49 +00:00
wip: synchro of calendar range
This commit is contained in:
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Messenger\Doctrine;
|
||||
|
||||
use Chill\CalendarBundle\Entity\Calendar;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
|
||||
class CalendarEntityListener
|
||||
{
|
||||
public function postPersistCalendar(Calendar $calendar, LifecycleEventArgs $args): void
|
||||
{
|
||||
}
|
||||
}
|
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\CalendarBundle\Messenger\Doctrine;
|
||||
|
||||
use Chill\CalendarBundle\Entity\CalendarRange;
|
||||
use Chill\CalendarBundle\Messenger\Message\CalendarRangeMessage;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Symfony\Component\Messenger\MessageBusInterface;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
|
||||
class CalendarRangeEntityListener
|
||||
{
|
||||
private MessageBusInterface $messageBus;
|
||||
|
||||
private Security $security;
|
||||
|
||||
public function __construct(MessageBusInterface $messageBus, Security $security)
|
||||
{
|
||||
$this->messageBus = $messageBus;
|
||||
$this->security = $security;
|
||||
}
|
||||
|
||||
public function postPersist(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
|
||||
{
|
||||
$this->messageBus->dispatch(
|
||||
new CalendarRangeMessage(
|
||||
$calendarRange,
|
||||
CalendarRangeMessage::CALENDAR_RANGE_PERSIST,
|
||||
$this->security->getUser()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
public function postUpdate(CalendarRange $calendarRange, LifecycleEventArgs $eventArgs): void
|
||||
{
|
||||
$this->messageBus->dispatch(
|
||||
new CalendarRangeMessage(
|
||||
$calendarRange,
|
||||
CalendarRangeMessage::CALENDAR_RANGE_UPDATE,
|
||||
$this->security->getUser()
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user