sidebar
This commit is contained in:
@@ -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))
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user