Add category path support to site documentation views

- Introduce `categoryPath` for `DocumentationService` methods.
- Resolve category paths dynamically based on parent or category ID.
This commit is contained in:
2026-07-25 23:10:18 +05:00
parent 2a26008e87
commit 1ee453dcfe
@@ -77,10 +77,16 @@ final class DocumentationService extends Service
return $this->errFobidden(__('Access is denied'));
}
$categoryPath = null;
if ($category->parent_id) {
$categoryPath = $this->documentationCategoryRepository->getPathFromRoot($category->parent_id, $documentation->getWebsiteTranslations()->getLanguage());
}
$data = array_merge($documentation->toArray(), [
'category' => $category,
'categories' => $this->getCategories($documentation, $category->id),
'documentations' => $this->getDocumentations($documentation, $category->id),
'categoryPath' => $categoryPath,
]);
return $this->resultSitePage($documentation->getProject(), $documentation->getWebsiteTranslations(), $data, \is_null($category->content?->title));
}
@@ -98,8 +104,14 @@ final class DocumentationService extends Service
return $this->errFobidden(__('Access is denied'));
}
$categoryPath = null;
if ($document->category_id) {
$categoryPath = $this->documentationCategoryRepository->getPathFromRoot($document->category_id, $documentation->getWebsiteTranslations()->getLanguage());
}
$data = array_merge($documentation->toArray(), [
'documentation' => $document,
'categoryPath' => $categoryPath,
]);
return $this->resultSitePage($documentation->getProject(), $documentation->getWebsiteTranslations(), $data, \is_null($document->content?->title));
}