add parent navigation

This commit is contained in:
Yisroel Baum 2026-06-22 10:04:58 +03:00
parent 3a9116dc3f
commit efc424183a
Signed by: yisroelbaum
GPG key ID: 0FA60884F75520A9
5 changed files with 125 additions and 8 deletions

View file

@ -55,6 +55,9 @@ class ElementController
$result->getChildElements(),
),
'element' => $this->buildElementPayload($element),
'parentElement' => $this->buildElementSummaryPayload(
$element->getParentElement(),
),
'siblingElements' => $this->buildElementSummaryPayloads(
$result->getSiblingElements(),
),
@ -328,16 +331,35 @@ class ElementController
{
$payloads = [];
foreach ($elements as $element) {
$payloads[] = [
'id' => $element->getId(),
'title' => $element->getTitle(),
'description' => $element->getDescription(),
];
$payload = $this->buildElementSummaryPayload($element);
if ($payload !== null) {
$payloads[] = $payload;
}
}
return $payloads;
}
/**
* @return array{
* id: int,
* title: string,
* description: string,
* }|null
*/
private function buildElementSummaryPayload(?Element $element): ?array
{
if ($element === null) {
return null;
}
return [
'id' => $element->getId(),
'title' => $element->getTitle(),
'description' => $element->getDescription(),
];
}
private function storageUrl(?string $path, string $folderPrefix): ?string
{
if ($path === null) {