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