refactor(bookmarks): remove factory chain, interfaces, and duplicated sort logic
Remove BookmarkRepositoryFactory, BookmarkServicesFactory, and all 3 repository interfaces — single-consumer abstractions with no polymorphism. Simplify container registrar to wire directly. Extract duplicated updateSortOrders() (60 identical lines in two repos) into SortOrderTrait. Consolidate icon labels from template into BookmarkService::allowedGroupIconLabels() single source of truth. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -4,18 +4,23 @@ namespace MintyPHP\Module\Bookmarks;
|
||||
|
||||
use MintyPHP\App\AppContainer;
|
||||
use MintyPHP\App\Container\ContainerRegistrar;
|
||||
use MintyPHP\Module\Bookmarks\Service\BookmarkRepositoryFactory;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkGroupRepository;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkNavigationRepository;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkRepository;
|
||||
use MintyPHP\Module\Bookmarks\Service\BookmarkService;
|
||||
use MintyPHP\Module\Bookmarks\Service\BookmarkServicesFactory;
|
||||
|
||||
final class BookmarksContainerRegistrar implements ContainerRegistrar
|
||||
{
|
||||
public function register(AppContainer $container): void
|
||||
{
|
||||
$container->set(BookmarkRepositoryFactory::class, static fn (): BookmarkRepositoryFactory => new BookmarkRepositoryFactory());
|
||||
$container->set(BookmarkServicesFactory::class, static fn (AppContainer $c): BookmarkServicesFactory => new BookmarkServicesFactory(
|
||||
$c->get(BookmarkRepositoryFactory::class)
|
||||
$container->set(BookmarkRepository::class, static fn (): BookmarkRepository => new BookmarkRepository());
|
||||
$container->set(BookmarkGroupRepository::class, static fn (): BookmarkGroupRepository => new BookmarkGroupRepository());
|
||||
$container->set(BookmarkNavigationRepository::class, static fn (): BookmarkNavigationRepository => new BookmarkNavigationRepository());
|
||||
|
||||
$container->set(BookmarkService::class, static fn (AppContainer $c): BookmarkService => new BookmarkService(
|
||||
$c->get(BookmarkRepository::class),
|
||||
$c->get(BookmarkGroupRepository::class),
|
||||
$c->get(BookmarkNavigationRepository::class)
|
||||
));
|
||||
$container->set(BookmarkService::class, static fn (AppContainer $c): BookmarkService => $c->get(BookmarkServicesFactory::class)->createBookmarkService());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user