Add category path resolution in DocumentationService

- Resolve `categoryPath` using `getPathFromRoot` based on the project's default language.
- Include the resolved `categoryPath` in the response.
This commit is contained in:
2026-07-25 01:18:52 +05:00
parent 54a2d84a00
commit 0d08276d44
@@ -87,18 +87,21 @@ final class DocumentationService extends Service
return $this->errFobidden(__('Access is denied'));
}
$defaultLanguage = $project->languages->where('is_default', 1)->first();
$documentation = new Documentation();
$categoryPath = null;
if ($categoryId !== null) {
$documentation->category_id = $categoryId;
$categoryPath = $this->documentationCategoryRepository->getPathFromRoot($categoryId, $defaultLanguage);
}
$defaultLanguage = $project->languages->where('is_default', 1)->first();
return $this->result([
'version' => $version,
'project' => $project,
'documentation' => $documentation,
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage),
'serviceTranslationEnable' => config('translation_service.enable', false),
'categoryPath' => $categoryPath,
]);
}
@@ -119,17 +122,20 @@ final class DocumentationService extends Service
return $this->errFobidden(__('Access is denied'));
}
$defaultLanguage = $project->languages->where('is_default', 1)->first();
$withCategories = [];
$categoryPath = null;
if ($documentation->category_id) {
$withCategories[] = $documentation->category_id;
$categoryPath = $this->documentationCategoryRepository->getPathFromRoot($documentation->category_id, $defaultLanguage);
}
$defaultLanguage = $project->languages->where('is_default', 1)->first();
return $this->result([
'version' => $version,
'project' => $project,
'documentation' => $documentation,
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage, null, $withCategories),
'serviceTranslationEnable' => config('translation_service.enable', false),
'categoryPath' => $categoryPath,
]);
}