From 39d54dd981565607461e843870c4e949c4ebafb8 Mon Sep 17 00:00:00 2001 From: Lukas Bestle Date: Sun, 14 Jan 2024 18:18:55 +0100 Subject: [PATCH] Support new Structure constructor syntax --- src/classes/ConfiguratorBlock.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/classes/ConfiguratorBlock.php b/src/classes/ConfiguratorBlock.php index 9205a38..15c21d5 100644 --- a/src/classes/ConfiguratorBlock.php +++ b/src/classes/ConfiguratorBlock.php @@ -2,6 +2,7 @@ namespace LukasBestle\Roomle; +use Kirby\Cms\App; use Kirby\Cms\Block; use Kirby\Cms\Page; use Kirby\Cms\Structure; @@ -209,8 +210,17 @@ public function targetUrl(): string|null */ public function variants(): Structure { - $field = $this->content()->variants(); - $structure = new Structure([], $field->parent()); + $field = $this->content()->variants(); + + // TODO: Always use array options once support for Kirby 3 is dropped; + // Psalm suppression can be removed then + $options = ['parent' => $field->parent()]; + if (version_compare(App::version() ?? '4.0.0', '4.0.0-alpha.4', '<') === true) { + $options = $options['parent']; + } + + /** @psalm-suppress PossiblyInvalidArgument */ + $structure = new Structure([], $options); foreach ($field->value() as $id => $props) { $variant = new ConfiguratorVariant([