refactor(notifications): remove factory indirection, interface, and listener duplication
Remove NotificationRepositoryFactory, NotificationServicesFactory, and NotificationRepositoryInterface — all single-consumer abstractions with no polymorphism benefit. Simplify container registrar to wire services directly. Extract shared listener logic (sanitizeTenantIds, resolveDisplayName, resolveUuid) into NotificationListenerTrait, eliminating duplication across 4 listeners. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Module\Notifications\Service;
|
||||
|
||||
use MintyPHP\Module\Notifications\Repository\NotificationRepository;
|
||||
use MintyPHP\Module\Notifications\Repository\NotificationRepositoryInterface;
|
||||
|
||||
class NotificationRepositoryFactory
|
||||
{
|
||||
private ?NotificationRepository $notificationRepository = null;
|
||||
|
||||
public function createNotificationRepository(): NotificationRepositoryInterface
|
||||
{
|
||||
return $this->notificationRepository ??= new NotificationRepository();
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
namespace MintyPHP\Module\Notifications\Service;
|
||||
|
||||
use MintyPHP\Module\Notifications\Repository\NotificationRepositoryInterface;
|
||||
use MintyPHP\Module\Notifications\Repository\NotificationRepository;
|
||||
use MintyPHP\Repository\Tenant\UserTenantRepositoryInterface;
|
||||
|
||||
class NotificationService
|
||||
@@ -18,7 +18,7 @@ class NotificationService
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private readonly NotificationRepositoryInterface $notificationRepository,
|
||||
private readonly NotificationRepository $notificationRepository,
|
||||
private readonly UserTenantRepositoryInterface $userTenantRepository
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace MintyPHP\Module\Notifications\Service;
|
||||
|
||||
use MintyPHP\Repository\Tenant\UserTenantRepositoryInterface;
|
||||
|
||||
class NotificationServicesFactory
|
||||
{
|
||||
private ?NotificationService $notificationService = null;
|
||||
|
||||
public function __construct(
|
||||
private readonly NotificationRepositoryFactory $notificationRepositoryFactory
|
||||
) {
|
||||
}
|
||||
|
||||
public function createNotificationService(UserTenantRepositoryInterface $userTenantRepository): NotificationService
|
||||
{
|
||||
return $this->notificationService ??= new NotificationService(
|
||||
$this->notificationRepositoryFactory->createNotificationRepository(),
|
||||
$userTenantRepository
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user