Add category path resolution in DocumentationVersionService

- Fetch category path using `getPathFromRoot` for the default project language.
- Pass resolved `categoryPath` to the view.
This commit is contained in:
2026-07-25 01:18:29 +05:00
parent a70e09bddc
commit 54a2d84a00
@@ -80,7 +80,10 @@ final class DocumentationVersionService extends Service
return $this->errFobidden(__('Access is denied'));
}
$defaultLanguage = $project->languages()->where('is_default', 1)->first();
$category = null;
$categoryPath = null;
if (!\is_null($categoryId)) {
$category = $this->documentationCategoryRepository->getCategoryById($categoryId);
if (\is_null($category) || $category->version_id !== $version->id) {
@@ -89,9 +92,9 @@ final class DocumentationVersionService extends Service
if ($user->cannot('view', $category)) {
return $this->errFobidden(__('Access is denied'));
}
$categoryPath = $this->documentationCategoryRepository->getPathFromRoot($category->id, $defaultLanguage);
}
$defaultLanguage = $project->languages()->where('is_default', 1)->first();
$with = [
'content' => function (HasOne $hasOne) use ($defaultLanguage) {
/** @var ?ProjectLanguage $defaultLanguage */
@@ -120,6 +123,7 @@ final class DocumentationVersionService extends Service
'project' => $project,
'category' => $category,
'categoryPath' => $categoryPath,
'categories' => $categories,
'documentations' => $documents,
]);