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:
@@ -80,7 +80,10 @@ final class DocumentationVersionService extends Service
|
|||||||
return $this->errFobidden(__('Access is denied'));
|
return $this->errFobidden(__('Access is denied'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$defaultLanguage = $project->languages()->where('is_default', 1)->first();
|
||||||
|
|
||||||
$category = null;
|
$category = null;
|
||||||
|
$categoryPath = null;
|
||||||
if (!\is_null($categoryId)) {
|
if (!\is_null($categoryId)) {
|
||||||
$category = $this->documentationCategoryRepository->getCategoryById($categoryId);
|
$category = $this->documentationCategoryRepository->getCategoryById($categoryId);
|
||||||
if (\is_null($category) || $category->version_id !== $version->id) {
|
if (\is_null($category) || $category->version_id !== $version->id) {
|
||||||
@@ -89,9 +92,9 @@ final class DocumentationVersionService extends Service
|
|||||||
if ($user->cannot('view', $category)) {
|
if ($user->cannot('view', $category)) {
|
||||||
return $this->errFobidden(__('Access is denied'));
|
return $this->errFobidden(__('Access is denied'));
|
||||||
}
|
}
|
||||||
|
$categoryPath = $this->documentationCategoryRepository->getPathFromRoot($category->id, $defaultLanguage);
|
||||||
}
|
}
|
||||||
|
|
||||||
$defaultLanguage = $project->languages()->where('is_default', 1)->first();
|
|
||||||
$with = [
|
$with = [
|
||||||
'content' => function (HasOne $hasOne) use ($defaultLanguage) {
|
'content' => function (HasOne $hasOne) use ($defaultLanguage) {
|
||||||
/** @var ?ProjectLanguage $defaultLanguage */
|
/** @var ?ProjectLanguage $defaultLanguage */
|
||||||
@@ -120,6 +123,7 @@ final class DocumentationVersionService extends Service
|
|||||||
'project' => $project,
|
'project' => $project,
|
||||||
|
|
||||||
'category' => $category,
|
'category' => $category,
|
||||||
|
'categoryPath' => $categoryPath,
|
||||||
'categories' => $categories,
|
'categories' => $categories,
|
||||||
'documentations' => $documents,
|
'documentations' => $documents,
|
||||||
]);
|
]);
|
||||||
|
|||||||
Reference in New Issue
Block a user