59 lines
1.8 KiB
PHP
59 lines
1.8 KiB
PHP
<?php
|
|
|
|
namespace App\Domain\Catalog;
|
|
|
|
/**
|
|
* @phpstan-type StructureNodeData array{
|
|
* role: string,
|
|
* position: int,
|
|
* composition_version_id: int|null,
|
|
* composition_id: int|null,
|
|
* content_element_version_id: int|null,
|
|
* content_element_id: int|null,
|
|
* editorial_kind: string|null,
|
|
* technical_kind: string|null,
|
|
* title: string,
|
|
* output_class: string|null,
|
|
* children: list<StructureNodeData>
|
|
* }
|
|
*/
|
|
readonly class StructureNode
|
|
{
|
|
/**
|
|
* @param list<StructureNode> $children
|
|
*/
|
|
public function __construct(
|
|
public string $role,
|
|
public int $position,
|
|
public ?int $compositionVersionId,
|
|
public ?int $compositionId,
|
|
public ?int $contentElementVersionId,
|
|
public ?int $contentElementId,
|
|
public ?string $editorialKindLabel,
|
|
public ?string $technicalKindLabel,
|
|
public ?string $outputClass,
|
|
public string $title,
|
|
public array $children = [],
|
|
) {}
|
|
|
|
/**
|
|
* @return array<string, mixed>
|
|
*/
|
|
public function toArray(): array
|
|
{
|
|
return [
|
|
'role' => $this->role,
|
|
'position' => $this->position,
|
|
'composition_version_id' => $this->compositionVersionId,
|
|
'composition_id' => $this->compositionId,
|
|
'content_element_version_id' => $this->contentElementVersionId,
|
|
'content_element_id' => $this->contentElementId,
|
|
'editorial_kind' => $this->editorialKindLabel,
|
|
'technical_kind' => $this->technicalKindLabel,
|
|
'output_class' => $this->outputClass,
|
|
'title' => $this->title,
|
|
'children' => array_map(fn (StructureNode $child): array => $child->toArray(), $this->children),
|
|
];
|
|
}
|
|
}
|