add parent navigation
This commit is contained in:
parent
3a9116dc3f
commit
efc424183a
5 changed files with 125 additions and 8 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue