This commit is contained in:
2024-03-19 23:05:57 +02:00
parent 137c338719
commit 1f03eebd08
34 changed files with 557 additions and 169 deletions
+29
View File
@@ -0,0 +1,29 @@
<?php
namespace Lucent\Schema\Sidebar;
use Lucent\Primitive\Collection;
use Lucent\Schema\Sidebar\Item\Item;
use Lucent\Schema\Sidebar\Item\LinkItem;
use Lucent\Schema\Sidebar\Item\SchemaItem;
class Section
{
/**
* @param Collection<Item> $items
*/
public function __construct(
public string $label,
public Collection $items
)
{
}
public static function fromArray(array $data): self
{
return new self(
label: $data["label"],
items: (new Collection($data["items"]))->map(fn($itemData) => isset($itemData["schema"]) ? SchemaItem::fromArray($itemData) : LinkItem::fromArray($itemData))
);
}
}