Erlaube Seiten unter mehrteiligen Adressen und reserviere die Pfade fester Routen
- Auffangroute und Pfadprüfung nehmen beliebig tiefe Adressen (/kurse/kinder) an; die Elternseite muss nicht existieren. - ReservedPaths sperrt jeden ersten Pfadteil fester Routen und des Ordners public/ (zur Laufzeit aus dem Router); frei bleiben nur /, /shop und /angebote. Eine bestehende Seite mit unverändertem Pfad bleibt speicherbar. - Menü: Eintrag im aktiven Pfad, wenn die aktuelle Seite unter seinem Ziel liegt. - Verwaltung: Hilfetext und Hinweis am Adressfeld, Sortierung nach Pfadteilen in Webpräsenz und Seitenauswahlen, Chip "Unterseite von ...". - ShopSwitchTest: Ein POST auf die entfernte Kaufadresse ergibt nun 405 statt 404, weil die Auffangroute die mehrteilige Adresse trifft (bei einteiligen Adressen schon bisher so). Keine Bestellung entsteht weiterhin; Begründung in ADR-72. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
eb9b203ecf
commit
6fcd3e39e9
11 files changed
+612
-30
No files matched your search
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Cms\NavigationItem;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PagePath;
|
||||
use App\Domain\Cms\Widgets\Support\SafeUrl;
|
||||
use App\Filament\Resources\NavigationItems\Pages\ManageNavigationItems;
|
||||
use Closure;
|
||||
@@ -70,7 +71,7 @@ public static function form(Schema $schema): Schema
|
||||
}),
|
||||
Select::make('page_id')
|
||||
->label('Interne Seite')
|
||||
->options(fn (): array => Page::query()->orderBy('path')->pluck('path', 'id')->all())
|
||||
->options(fn (): array => Page::query()->get()->sort(fn (Page $a, Page $b): int => PagePath::compare($a->path, $b->path))->pluck('path', 'id')->all())
|
||||
->searchable()
|
||||
->helperText('Bevorzugt: eine CMS-Seite wählen. Dann folgt der Link automatisch einer Pfadänderung.'),
|
||||
TextInput::make('url')
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
|
||||
use App\Domain\Catalog\Pillar;
|
||||
use App\Domain\Cms\Page;
|
||||
use App\Domain\Cms\PagePath;
|
||||
use App\Domain\Cms\PageService;
|
||||
use App\Filament\Resources\Pages\Pages\CreatePage;
|
||||
use App\Filament\Resources\Pages\Pages\EditPage;
|
||||
@@ -36,6 +37,28 @@ class PageResource extends Resource
|
||||
|
||||
protected static ?string $recordTitleAttribute = 'path';
|
||||
|
||||
/**
|
||||
* Hilfetext am Adressfeld: Form der Adresse und, falls die übergeordnete Stufe keine Seite ist, ein Hinweis.
|
||||
*/
|
||||
public static function pathHelp(?string $state): string
|
||||
{
|
||||
$help = 'Zum Beispiel /praevention oder /kurse/kinder. Beliebig viele Ebenen, nur Kleinbuchstaben, Ziffern und Bindestriche.';
|
||||
|
||||
if (! is_string($state) || trim($state) === '') {
|
||||
return $help;
|
||||
}
|
||||
|
||||
$service = app(PageService::class);
|
||||
|
||||
try {
|
||||
$parent = $service->missingParent($service->normalizePath($state));
|
||||
} catch (ValidationException) {
|
||||
return $help;
|
||||
}
|
||||
|
||||
return $parent === null ? $help : $help.' Hinweis: '.$parent.' ist keine Seite; diese Adresse ergibt 404, bis dort eine Seite liegt.';
|
||||
}
|
||||
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
return $schema->components([
|
||||
@@ -48,8 +71,9 @@ public static function form(Schema $schema): Schema
|
||||
TextInput::make('path')
|
||||
->label('Pfad')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText('Zum Beispiel / oder /praevention'),
|
||||
->maxLength(PagePath::MAX_LENGTH)
|
||||
->live(onBlur: true)
|
||||
->helperText(fn (?string $state): string => self::pathHelp($state)),
|
||||
TextInput::make('seo_title')
|
||||
->label('SEO-Titel')
|
||||
->maxLength(255),
|
||||
@@ -115,8 +139,9 @@ public static function table(Table $table): Table
|
||||
TextInput::make('path')
|
||||
->label('Pfad der neuen Seite')
|
||||
->required()
|
||||
->maxLength(255)
|
||||
->helperText('Zum Beispiel /neue-landingpage'),
|
||||
->maxLength(PagePath::MAX_LENGTH)
|
||||
->live(onBlur: true)
|
||||
->helperText(fn (?string $state): string => self::pathHelp($state)),
|
||||
])
|
||||
->modalSubmitActionLabel('Duplizieren')
|
||||
->action(function (Page $record, array $data, PageService $service) {
|
||||
|
||||
Reference in new issue
Block a user