Rebuild DEEG as a fifth installation, add stepped forms and a plugin system, and clear the review backlog
Forms gained steps, conditions, image choices, number fields with units and a summary step; the DEEG price finder uses all of it. Plugins are manifest plus Twig: blocks, settings, containers, routes, presets and theme packs, switched per installation. The review backlog is done: archive pages render through the normal page pipeline, forms and post lists work inside areas and sections, repeated sections get their own ids, breakpoints and colours come from the palette, backup and update work on MySQL and lock each other out. The task worker no longer shortens a process that has no time limit: set_time_limit() sets the limit instead of extending it, which turned an unlimited CLI run into eighty seconds and killed the full test suite far away from the scheduler. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
66ff68abf8
commit
c8a8fa7460
74 files changed
+5352
-243
No files matched your search
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
|
||||
namespace App\Twig;
|
||||
|
||||
use App\Content\MediaLibrary;
|
||||
use App\Domain\InvalidDocument;
|
||||
use App\Plugin\PluginRegistry;
|
||||
use Twig\Extension\AbstractExtension;
|
||||
use Twig\Loader\FilesystemLoader;
|
||||
use Twig\TwigFunction;
|
||||
|
||||
/**
|
||||
* Was eine Plugin-Vorlage vom Kern bekommt: die Definition ihres Bausteins, die geprüften
|
||||
* Eigenschaften und Bilder aus der Mediathek. Mehr nicht - keine Datenbank, keine Einstellungen.
|
||||
*/
|
||||
final class PluginExtension extends AbstractExtension
|
||||
{
|
||||
public function __construct(private PluginRegistry $plugins, private MediaLibrary $media, FilesystemLoader $loader)
|
||||
{
|
||||
// Der Namensraum @plugins zeigt auf den Pluginordner - aber nur, wenn es ihn gibt. Ein
|
||||
// fester Pfad in twig.yaml liesse eine Installation ohne plugins/ mit einem Ladefehler
|
||||
// stehen, bevor sie eine einzige Seite ausgeliefert hat.
|
||||
$directory = $plugins->directory();
|
||||
if (is_dir($directory) && !in_array($directory, $loader->getPaths('plugins'), true)) {
|
||||
$loader->addPath($directory, 'plugins');
|
||||
}
|
||||
}
|
||||
|
||||
public function getFunctions(): array
|
||||
{
|
||||
return [
|
||||
new TwigFunction('kant_plugin_block', $this->plugins->block(...)),
|
||||
new TwigFunction('kant_plugin_props', $this->props(...)),
|
||||
new TwigFunction('kant_plugin_media', $this->mediaItem(...)),
|
||||
new TwigFunction('kant_plugin_settings', $this->plugins->settingsOf(...)),
|
||||
];
|
||||
}
|
||||
|
||||
/** Die geprüften Eigenschaften eines Bausteins - oder null, wenn sie nicht ins Schema passen. */
|
||||
public function props(array $block): ?array
|
||||
{
|
||||
try {
|
||||
return $this->plugins->validateProps((string) ($block['type'] ?? ''), is_array($block['props'] ?? null) ? $block['props'] : []);
|
||||
} catch (InvalidDocument) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Ein Bild der Mediathek für eine Vorlage: Kennung, Titel, Alternativtext und die Fassungen
|
||||
* (src, width, height), die kleinste zuerst.
|
||||
*/
|
||||
public function mediaItem(string $id): ?array
|
||||
{
|
||||
if (1 !== preg_match('/^[a-f0-9]{32}$/D', $id)) {
|
||||
return null;
|
||||
}
|
||||
$item = $this->media->find($id);
|
||||
if (null === $item || ($item['archived'] ?? false)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return ['id' => $item['id'], 'title' => (string) ($item['title'] ?? ''), 'alt' => (string) ($item['alt'] ?? ''), 'variants' => $item['variants']];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user