1
0

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:
2026-03-26 12:01:11 +01:00
parent 6ea3c2b88c
commit e746a2e874
13 changed files with 83 additions and 167 deletions

View File

@@ -5,7 +5,7 @@ namespace MintyPHP\Module\Notifications\Repository;
use MintyPHP\DB;
use MintyPHP\Repository\Support\RepositoryArrayHelper;
class NotificationRepository implements NotificationRepositoryInterface
class NotificationRepository
{
private const DEDUPE_WINDOW_SECONDS = 1800;

View File

@@ -1,26 +0,0 @@
<?php
namespace MintyPHP\Module\Notifications\Repository;
interface NotificationRepositoryInterface
{
/** @return int|false Insert ID on success, false on failure */
public function create(array $data): int|false;
/**
* @return list<array<string, mixed>>
*/
public function listByUser(int $userId, ?int $tenantId, int $limit, int $offset): array;
public function countUnreadByUser(int $userId, ?int $tenantId): int;
public function markRead(int $id, int $userId, ?int $tenantId): bool;
public function markAllReadByUser(int $userId, ?int $tenantId): int;
public function delete(int $id, int $userId, ?int $tenantId): bool;
public function deleteAllByUser(int $userId): int;
public function purgeReadOlderThanDays(int $days): int;
}