mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-09-04 05:44:58 +00:00
apply more cs rules for php-cs
This commit is contained in:
@@ -16,9 +16,7 @@ use Chill\MainBundle\Entity\NotificationComment;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\NotificationRepository;
|
||||
use Chill\MainBundle\Templating\UI\NotificationCounterInterface;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Event\PostUpdateEventArgs;
|
||||
use Doctrine\ORM\Event\PreFlushEventArgs;
|
||||
use Psr\Cache\CacheItemPoolInterface;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
@@ -59,7 +57,7 @@ final readonly class NotificationByUserCounter implements NotificationCounterInt
|
||||
|
||||
public static function generateCacheKeyUnreadNotificationByUser(User $user): string
|
||||
{
|
||||
return 'chill_main_notif_unread_by_' . $user->getId();
|
||||
return 'chill_main_notif_unread_by_'.$user->getId();
|
||||
}
|
||||
|
||||
public function onEditNotificationComment(NotificationComment $notificationComment, PostPersistEventArgs $eventArgs): void
|
||||
|
@@ -13,7 +13,6 @@ namespace Chill\MainBundle\Notification\Email;
|
||||
|
||||
use Chill\MainBundle\Entity\Notification;
|
||||
use Chill\MainBundle\Entity\NotificationComment;
|
||||
use Doctrine\ORM\Event\LifecycleEventArgs;
|
||||
use Doctrine\ORM\Event\PostPersistEventArgs;
|
||||
use Doctrine\ORM\Event\PostUpdateEventArgs;
|
||||
use Psr\Log\LoggerInterface;
|
||||
@@ -46,7 +45,7 @@ class NotificationMailer
|
||||
$email = new TemplatedEmail();
|
||||
$email
|
||||
->to($dest->getEmail())
|
||||
->subject('Re: ' . $comment->getNotification()->getTitle())
|
||||
->subject('Re: '.$comment->getNotification()->getTitle())
|
||||
->textTemplate('@ChillMain/Notification/email_notification_comment_persist.fr.md.twig')
|
||||
->context([
|
||||
'comment' => $comment,
|
||||
|
@@ -15,7 +15,6 @@ use Chill\MainBundle\Notification\NotificationPersisterInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
|
||||
use Symfony\Component\HttpKernel\Event\TerminateEvent;
|
||||
use function count;
|
||||
|
||||
class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberInterface
|
||||
{
|
||||
@@ -39,7 +38,7 @@ class PersistNotificationOnTerminateEventSubscriber implements EventSubscriberIn
|
||||
|
||||
private function persistNotifications(): void
|
||||
{
|
||||
if (0 < count($this->persister->getWaitingNotifications())) {
|
||||
if (0 < \count($this->persister->getWaitingNotifications())) {
|
||||
foreach ($this->persister->getWaitingNotifications() as $notification) {
|
||||
$this->em->persist($notification);
|
||||
}
|
||||
|
@@ -11,6 +11,4 @@ declare(strict_types=1);
|
||||
|
||||
namespace Chill\MainBundle\Notification\Exception;
|
||||
|
||||
use RuntimeException;
|
||||
|
||||
class NotificationHandlerNotFound extends RuntimeException {}
|
||||
class NotificationHandlerNotFound extends \RuntimeException {}
|
||||
|
@@ -13,17 +13,12 @@ namespace Chill\MainBundle\Notification;
|
||||
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Swift_Mailer;
|
||||
use Swift_Message;
|
||||
use Symfony\Component\Mailer\MailerInterface;
|
||||
use Symfony\Component\Mime\Email;
|
||||
use Symfony\Component\Routing\RouterInterface;
|
||||
use Symfony\Component\Templating\EngineInterface;
|
||||
use Symfony\Contracts\Translation\TranslatorInterface;
|
||||
use Twig\Environment;
|
||||
|
||||
use function call_user_func;
|
||||
|
||||
/**
|
||||
* Class Mailer
|
||||
* Classe d'aide pour l'envoi de notification.
|
||||
@@ -37,19 +32,16 @@ class Mailer
|
||||
/**
|
||||
* Mailer constructor.
|
||||
*
|
||||
* @param $routeParameters
|
||||
* @param mixed[] $routeParameters
|
||||
*/
|
||||
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly \Twig\Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) {}
|
||||
public function __construct(private readonly MailerInterface $mailer, private readonly LoggerInterface $logger, private readonly Environment $twig, private readonly RouterInterface $router, private readonly TranslatorInterface $translator, protected $routeParameters) {}
|
||||
|
||||
/**
|
||||
* @param $template
|
||||
* @return string
|
||||
*
|
||||
* @throws \Twig\Error\LoaderError
|
||||
* @throws \Twig\Error\RuntimeError
|
||||
* @throws \Twig\Error\SyntaxError
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderContentToUser(User $to, $template, array $parameters = [])
|
||||
{
|
||||
@@ -72,15 +64,15 @@ class Mailer
|
||||
/**
|
||||
* Envoie une notification à un utilisateur.
|
||||
*
|
||||
* @param array $subject Subject of the message [ 0 => $message (required), 1 => $parameters (optional), 3 => $domain (optional) ]
|
||||
* @param array $bodies The bodies. An array where keys are the contentType and values the bodies
|
||||
* @param array $subject Subject of the message [ 0 => $message (required), 1 => $parameters (optional), 3 => $domain (optional) ]
|
||||
* @param array $bodies The bodies. An array where keys are the contentType and values the bodies
|
||||
* @param callable $callback a callback to customize the message (add attachment, etc.)
|
||||
*/
|
||||
public function sendNotification(
|
||||
mixed $recipient,
|
||||
array $subject,
|
||||
array $bodies,
|
||||
?callable $callback = null,
|
||||
callable $callback = null,
|
||||
mixed $force = false
|
||||
) {
|
||||
$fromEmail = $this->routeParameters['from_email'];
|
||||
@@ -104,12 +96,12 @@ class Mailer
|
||||
}
|
||||
|
||||
if (null !== $callback) {
|
||||
call_user_func($callback, $email);
|
||||
\call_user_func($callback, $email);
|
||||
}
|
||||
|
||||
$this->logger->info('[notification] Sending notification', [
|
||||
'to' => $email->getTo(),
|
||||
'subject' => $email->getSubject()
|
||||
'subject' => $email->getSubject(),
|
||||
]);
|
||||
|
||||
$this->mailer->send($email);
|
||||
|
@@ -15,7 +15,6 @@ use Chill\MainBundle\Entity\Notification;
|
||||
use Chill\MainBundle\Entity\User;
|
||||
use Chill\MainBundle\Repository\NotificationRepository;
|
||||
use Symfony\Component\Security\Core\Security;
|
||||
use function array_key_exists;
|
||||
|
||||
/**
|
||||
* Helps to find if a notification exist for a given entity.
|
||||
@@ -28,11 +27,12 @@ class NotificationPresence
|
||||
|
||||
/**
|
||||
* @param list<array{relatedEntityClass: class-string, relatedEntityId: int}> $more
|
||||
*
|
||||
* @return array{unread: int, sent: int, total: int}
|
||||
*/
|
||||
public function countNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId, array $more = [], array $options = []): array
|
||||
{
|
||||
if ([] === $more && array_key_exists($relatedEntityClass, $this->cache) && array_key_exists($relatedEntityId, $this->cache[$relatedEntityClass])) {
|
||||
if ([] === $more && \array_key_exists($relatedEntityClass, $this->cache) && \array_key_exists($relatedEntityId, $this->cache[$relatedEntityClass])) {
|
||||
return $this->cache[$relatedEntityClass][$relatedEntityId];
|
||||
}
|
||||
|
||||
@@ -58,6 +58,7 @@ class NotificationPresence
|
||||
|
||||
/**
|
||||
* @param list<array{relatedEntityClass: class-string, relatedEntityId: int}> $more
|
||||
*
|
||||
* @return array|Notification[]
|
||||
*/
|
||||
public function getNotificationsForClassAndEntity(string $relatedEntityClass, int $relatedEntityId, array $more = []): array
|
||||
|
Reference in New Issue
Block a user