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