This commit is contained in:
2022-04-22 11:41:38 +02:00
parent abc3caee00
commit f7d9551dc1
6 changed files with 53 additions and 16 deletions

View File

@@ -1,5 +1,14 @@
<?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\MainBundle\Notification\EventListener;
use Chill\MainBundle\Notification\NotificationPersisterInterface;
@@ -9,7 +18,6 @@ use Symfony\Component\HttpKernel\Event\TerminateEvent;
class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface
{
private EntityManagerInterface $em;
private NotificationPersisterInterface $persister;
@@ -25,7 +33,7 @@ class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberIn
return [
'kernel.terminate' => [
['onKernelTerminate', 1024], // we must ensure that the priority is before sending email
]
],
];
}

View File

@@ -1,5 +1,14 @@
<?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\MainBundle\Notification;
use Chill\MainBundle\Entity\Notification;
@@ -8,11 +17,6 @@ class NotificationPersister implements NotificationPersisterInterface
{
private array $waitingNotifications = [];
public function persist(Notification $notification): void
{
$this->waitingNotifications[] = $notification;
}
/**
* @return array|Notification[]
*/
@@ -20,4 +24,9 @@ class NotificationPersister implements NotificationPersisterInterface
{
return $this->waitingNotifications;
}
public function persist(Notification $notification): void
{
$this->waitingNotifications[] = $notification;
}
}

View File

@@ -1,11 +1,20 @@
<?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\MainBundle\Notification;
use Chill\MainBundle\Entity\Notification;
/**
* Store the notification
* Store the notification.
*
* Those notification will be stored into database by the kernel. This
* will also ensure that this happens outside of regular operations
@@ -13,10 +22,10 @@ use Chill\MainBundle\Entity\Notification;
*/
interface NotificationPersisterInterface
{
public function persist(Notification $notification): void;
/**
* @return array|Notification[]
*/
public function getWaitingNotifications(): array;
public function persist(Notification $notification): void;
}

View File

@@ -1,5 +1,14 @@
<?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 Notification\EventListener;
use Chill\MainBundle\Entity\Notification;
@@ -11,7 +20,11 @@ use Prophecy\Argument;
use Prophecy\PhpUnit\ProphecyTrait;
use Symfony\Component\HttpKernel\Event\TerminateEvent;
class PersistNotificationOnTerminateEventSubscriberTest extends TestCase
/**
* @internal
* @coversNothing
*/
final class PersistNotificationOnTerminateEventSubscriberTest extends TestCase
{
use ProphecyTrait;