Menüs ersetzen die fest verdrahtete Navigation (Arbeitspaket A)
Migration 20260912000500 legt eine Tabelle menu an: ein Menü je Platz (header, footer) und Sprache, Elementbaum als JSON, Version für dieselbe Konflikterkennung wie bei Seiten. Ein Eintrag verweist auf eine Seite, auf ein Sprungziel innerhalb einer Seite oder auf eine Adresse (HTTPS, lokaler Pfad, mailto:, tel:). Seitenverweise speichern die Seiten-ID, nie den Pfad - ein Eintrag folgt damit einer umbenannten Seite. Beim Rendern fallen Einträge zu gelöschten oder unveröffentlichten Seiten heraus, ohne den gespeicherten Baum zu ändern und ohne die übrigen Einträge zu verlieren. Die Verwaltung nutzt eine nummerierte Zeilenliste statt Drag-and-drop und funktioniert damit vollständig ohne JavaScript; Untermenüs in der Ausgabe über details/summary. tests/bootstrap.php verwirft var/cache/test je Lauf. Ohne Debug prüft Symfony weder den kompilierten Container noch die Vorlagen auf Aktualität, was zweimal ein falsches Testergebnis erzeugt hat. Geprüft: 79 PHP-Tests / 285 Assertions unter PHP 8.2.12 und 8.4.22, 11 JavaScript-Modelltests, Lint/Format/Container, Migration zuerst gegen eine Datenbankkopie, wiederholtes Seeding. Keine Browser- oder Lighthouse-Läufe. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4a60adf7d7
commit
de9d6e3da8
22 files changed
+765
-19
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Command;
|
||||
|
||||
use App\Content\DemoContent;
|
||||
use App\Content\MenuRepository;
|
||||
use App\Content\PageRepository;
|
||||
use Doctrine\DBAL\Connection;
|
||||
use Symfony\Component\Console\Attribute\AsCommand;
|
||||
@@ -13,7 +14,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
#[AsCommand(name: 'cms:seed-demo', description: 'Create missing demo pages without overwriting existing content.')]
|
||||
final class SeedDemoCommand extends Command
|
||||
{
|
||||
public function __construct(private Connection $db, private PageRepository $pages)
|
||||
public function __construct(private Connection $db, private PageRepository $pages, private MenuRepository $menus)
|
||||
{
|
||||
parent::__construct();
|
||||
}
|
||||
@@ -35,8 +36,40 @@ final class SeedDemoCommand extends Command
|
||||
$this->pages->publish($id, $revision, 1);
|
||||
$output->writeln('Created: '.$slug);
|
||||
}
|
||||
$this->seedMenus($output);
|
||||
});
|
||||
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
|
||||
/** Only fills an empty slot, so an edited menu is never overwritten by seeding again. */
|
||||
private function seedMenus(OutputInterface $output): void
|
||||
{
|
||||
$existing = $this->menus->all();
|
||||
$pages = [];
|
||||
foreach ($this->db->fetchAllAssociative('SELECT id, path FROM page WHERE website_id = ? AND locale = ?', ['default', 'de']) as $page) {
|
||||
$pages[$page['path']] = $page['id'];
|
||||
}
|
||||
$defaults = [
|
||||
'header' => [['Überblick', 'home'], ['Grundlagen', 'grundlagen'], ['Projektstand', 'projektstand']],
|
||||
'footer' => [['Überblick', 'home']],
|
||||
];
|
||||
foreach ($defaults as $slot => $entries) {
|
||||
if (isset($existing[$slot])) {
|
||||
$output->writeln('Menu unchanged: '.$slot);
|
||||
continue;
|
||||
}
|
||||
$items = [];
|
||||
foreach ($entries as [$label, $path]) {
|
||||
if (isset($pages[$path])) {
|
||||
$items[] = ['label' => $label, 'type' => 'page', 'pageId' => $pages[$path], 'anchor' => '', 'children' => []];
|
||||
}
|
||||
}
|
||||
if ([] === $items) {
|
||||
continue;
|
||||
}
|
||||
$this->menus->save($slot, MenuRepository::SLOTS[$slot], $items, 0);
|
||||
$output->writeln('Menu created: '.$slot);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user