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'));
|
return $this->errFobidden(__('Access is denied'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$defaultLanguage = $project->languages->where('is_default', 1)->first();
|
||||||
$documentation = new Documentation();
|
$documentation = new Documentation();
|
||||||
|
$categoryPath = null;
|
||||||
if ($categoryId !== null) {
|
if ($categoryId !== null) {
|
||||||
$documentation->category_id = $categoryId;
|
$documentation->category_id = $categoryId;
|
||||||
|
$categoryPath = $this->documentationCategoryRepository->getPathFromRoot($categoryId, $defaultLanguage);
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultLanguage = $project->languages->where('is_default', 1)->first();
|
|
||||||
return $this->result([
|
return $this->result([
|
||||||
'version' => $version,
|
'version' => $version,
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
'documentation' => $documentation,
|
'documentation' => $documentation,
|
||||||
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage),
|
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage),
|
||||||
'serviceTranslationEnable' => config('translation_service.enable', false),
|
'serviceTranslationEnable' => config('translation_service.enable', false),
|
||||||
|
'categoryPath' => $categoryPath,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -119,17 +122,20 @@ final class DocumentationService extends Service
|
|||||||
return $this->errFobidden(__('Access is denied'));
|
return $this->errFobidden(__('Access is denied'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$defaultLanguage = $project->languages->where('is_default', 1)->first();
|
||||||
$withCategories = [];
|
$withCategories = [];
|
||||||
|
$categoryPath = null;
|
||||||
if ($documentation->category_id) {
|
if ($documentation->category_id) {
|
||||||
$withCategories[] = $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([
|
return $this->result([
|
||||||
'version' => $version,
|
'version' => $version,
|
||||||
'project' => $project,
|
'project' => $project,
|
||||||
'documentation' => $documentation,
|
'documentation' => $documentation,
|
||||||
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage, null, $withCategories),
|
'categories' => $this->documentationCategoryRepository->getForSelect($version, $defaultLanguage, null, $withCategories),
|
||||||
'serviceTranslationEnable' => config('translation_service.enable', false),
|
'serviceTranslationEnable' => config('translation_service.enable', false),
|
||||||
|
'categoryPath' => $categoryPath,
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user