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:
@@ -10,9 +10,8 @@ use MintyPHP\Module\Notifications\Listeners\UserAssignmentChangedNotificationLis
|
||||
use MintyPHP\Module\Notifications\Listeners\UserCreatedNotificationListener;
|
||||
use MintyPHP\Module\Notifications\Listeners\UserDeactivatedNotificationListener;
|
||||
use MintyPHP\Module\Notifications\Listeners\UserDeletedNotificationListener;
|
||||
use MintyPHP\Module\Notifications\Service\NotificationRepositoryFactory;
|
||||
use MintyPHP\Module\Notifications\Repository\NotificationRepository;
|
||||
use MintyPHP\Module\Notifications\Service\NotificationService;
|
||||
use MintyPHP\Module\Notifications\Service\NotificationServicesFactory;
|
||||
use MintyPHP\Repository\Tenant\UserTenantRepository;
|
||||
use MintyPHP\Repository\User\UserReadRepository;
|
||||
use MintyPHP\Service\Access\PermissionService;
|
||||
@@ -24,13 +23,11 @@ final class NotificationsContainerRegistrar implements ContainerRegistrar
|
||||
$container->set(NotificationsAuthorizationPolicy::class, static fn (AppContainer $c): NotificationsAuthorizationPolicy => new NotificationsAuthorizationPolicy(
|
||||
$c->get(PermissionService::class)
|
||||
));
|
||||
$container->set(NotificationRepositoryFactory::class, static fn (): NotificationRepositoryFactory => new NotificationRepositoryFactory());
|
||||
|
||||
$container->set(NotificationServicesFactory::class, static fn (AppContainer $c): NotificationServicesFactory => new NotificationServicesFactory(
|
||||
$c->get(NotificationRepositoryFactory::class)
|
||||
));
|
||||
$container->set(NotificationRepository::class, static fn (): NotificationRepository => new NotificationRepository());
|
||||
|
||||
$container->set(NotificationService::class, static fn (AppContainer $c): NotificationService => $c->get(NotificationServicesFactory::class)->createNotificationService(
|
||||
$container->set(NotificationService::class, static fn (AppContainer $c): NotificationService => new NotificationService(
|
||||
$c->get(NotificationRepository::class),
|
||||
$c->get(UserTenantRepository::class)
|
||||
));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user