Moves bookmarks from core hardcoding into modules/bookmarks/ as a
fully self-contained module, following the same pattern as addressbook.
Module contributions via platform slots:
- aside.tab_panel: bookmark sidebar panel
- topbar.right_item: bookmark toggle button
- layout.body_end_template: bookmark/group dialogs
- layout.head_style: bookmark CSS (form + sidebar)
- runtime.component: bookmark-save and bookmark-panel (phase: late)
- search.resource_item: bookmarks in global search (user-scoped via {{userId}})
Backend fully in module namespace (MintyPHP\Module\Bookmarks\*):
- Service: BookmarkService, BookmarkServicesFactory, BookmarkRepositoryFactory
- Repository: BookmarkRepository, BookmarkGroupRepository, BookmarkNavigationRepository
- Support: BookmarkUrlNormalizer
- Providers: BookmarksSessionProvider, BookmarksLayoutProvider, BookmarksSearchProvider
Core cleanup:
- Removed all bookmark-specific markup from core templates
- Removed core DI registrations for bookmark services
- Removed core bookmark pages, JS, CSS
- AuthSessionTenantContextService delegates to module SessionProvider
Architecture guards:
- NoBookmarksHardcodingTest: verifies zero bookmark references in core
- testModuleClassesUseModuleNamespace: prevents core namespace leakage
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
46 lines
1.2 KiB
PHP
46 lines
1.2 KiB
PHP
<?php
|
|
|
|
use MintyPHP\Http\SessionStoreInterface;
|
|
use MintyPHP\Router;
|
|
use MintyPHP\Module\Bookmarks\Service\BookmarkService;
|
|
use MintyPHP\Session;
|
|
use MintyPHP\Support\Guard;
|
|
|
|
Guard::requireLogin();
|
|
|
|
if (requestInput()->method() !== 'POST') {
|
|
http_response_code(405);
|
|
Router::json(['ok' => false, 'error' => 'method_not_allowed']);
|
|
return;
|
|
}
|
|
|
|
if (!Session::checkCsrfToken()) {
|
|
http_response_code(403);
|
|
Router::json(['ok' => false, 'error' => 'csrf']);
|
|
return;
|
|
}
|
|
|
|
$session = app(SessionStoreInterface::class)->all();
|
|
$userId = (int) ($session['user']['id'] ?? 0);
|
|
if ($userId <= 0) {
|
|
http_response_code(401);
|
|
Router::json(['ok' => false, 'error' => 'unauthorized']);
|
|
return;
|
|
}
|
|
|
|
$name = trim((string) requestInput()->body('name'));
|
|
$icon = trim((string) requestInput()->body('icon'));
|
|
$groupId = requestInput()->body('id');
|
|
$groupId = ($groupId !== null && $groupId !== '') ? (int) $groupId : null;
|
|
|
|
$service = app(BookmarkService::class);
|
|
$result = $service->saveGroup($userId, $name, $icon, $groupId);
|
|
|
|
if ($result['ok']) {
|
|
app(SessionStoreInterface::class)->set('module.bookmarks.grouped', $service->listGroupedForUser($userId));
|
|
} else {
|
|
http_response_code(400);
|
|
}
|
|
|
|
Router::json($result);
|