Skip to content

Commit

Permalink
Support new Structure constructor syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasbestle committed Jan 14, 2024
1 parent 8456dd6 commit 39d54dd
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/classes/ConfiguratorBlock.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace LukasBestle\Roomle;

use Kirby\Cms\App;
use Kirby\Cms\Block;
use Kirby\Cms\Page;
use Kirby\Cms\Structure;
Expand Down Expand Up @@ -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([
Expand Down

0 comments on commit 39d54dd

Please sign in to comment.