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:
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace MintyPHP\Module\Bookmarks\Service;
|
||||
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkGroupRepositoryInterface;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkNavigationRepositoryInterface;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkRepositoryInterface;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkGroupRepository;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkNavigationRepository;
|
||||
use MintyPHP\Module\Bookmarks\Repository\BookmarkRepository;
|
||||
use MintyPHP\Module\Bookmarks\Support\BookmarkUrlNormalizer;
|
||||
|
||||
class BookmarkService
|
||||
@@ -23,9 +23,9 @@ class BookmarkService
|
||||
];
|
||||
|
||||
public function __construct(
|
||||
private readonly BookmarkRepositoryInterface $bookmarkRepository,
|
||||
private readonly BookmarkGroupRepositoryInterface $groupRepository,
|
||||
private readonly BookmarkNavigationRepositoryInterface $navigationRepository
|
||||
private readonly BookmarkRepository $bookmarkRepository,
|
||||
private readonly BookmarkGroupRepository $groupRepository,
|
||||
private readonly BookmarkNavigationRepository $navigationRepository
|
||||
) {
|
||||
}
|
||||
|
||||
@@ -35,6 +35,33 @@ class BookmarkService
|
||||
return self::ALLOWED_GROUP_ICONS;
|
||||
}
|
||||
|
||||
/** @return array<string, string> icon class => translated label */
|
||||
public static function allowedGroupIconLabels(): array
|
||||
{
|
||||
return [
|
||||
'bi-house' => t('Icon: Home'),
|
||||
'bi-people' => t('Icon: People'),
|
||||
'bi-person' => t('Icon: Person'),
|
||||
'bi-folder' => t('Icon: Folder'),
|
||||
'bi-file-text' => t('Icon: Document'),
|
||||
'bi-gear' => t('Icon: Settings'),
|
||||
'bi-shield-lock' => t('Icon: Security'),
|
||||
'bi-bar-chart' => t('Icon: Chart'),
|
||||
'bi-envelope' => t('Icon: Mail'),
|
||||
'bi-calendar' => t('Icon: Calendar'),
|
||||
'bi-clock' => t('Icon: Clock'),
|
||||
'bi-star' => t('Icon: Star'),
|
||||
'bi-heart' => t('Icon: Heart'),
|
||||
'bi-flag' => t('Icon: Flag'),
|
||||
'bi-bookmark' => t('Icon: Bookmark'),
|
||||
'bi-pin-map' => t('Icon: Location'),
|
||||
'bi-lightning' => t('Icon: Lightning'),
|
||||
'bi-database' => t('Icon: Database'),
|
||||
'bi-globe' => t('Icon: Globe'),
|
||||
'bi-code-slash' => t('Icon: Code'),
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array{groups: list<array<string, mixed>>, ungrouped: list<array<string, mixed>>}
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user