Skip to content

Commit ae8cd7e

Browse files
committed
refactor: more code improvements for the category class
1 parent 67c0ef0 commit ae8cd7e

File tree

11 files changed

+105
-179
lines changed

11 files changed

+105
-179
lines changed

phpmyfaq/index.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -438,13 +438,13 @@
438438
$category->expandTo($cat);
439439
}
440440

441-
if (isset($cat) && ($cat !== 0) && ($id === 0) && isset($category->categoryName[$cat]['name'])) {
441+
if (isset($cat) && ($cat !== 0) && ($id === 0) && $category->getCategoryName($cat) !== null) {
442442
$seoEntity
443443
->setSeoType(SeoType::CATEGORY)
444444
->setReferenceId($cat);
445445
$seoData = $seo->get($seoEntity);
446-
$title = $seoData->getTitle() ?? $category->categoryName[$cat]['name'];
447-
$metaDescription = $seoData->getDescription() ?? $category->categoryName[$cat]['description'];
446+
$title = $seoData->getTitle() ?? $category->getCategoryName($cat);
447+
$metaDescription = $seoData->getDescription() ?? $category->getCategoryDescription($cat);
448448
}
449449

450450
//

phpmyfaq/show.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
$selectedCategoryId = null;
4646
}
4747

48-
if (!is_null($selectedCategoryId) && !isset($category->categoryName[$selectedCategoryId])) {
48+
if (!is_null($selectedCategoryId) && !isset($category->getCategoryName($selectedCategoryId))) {
4949
$response = new Response();
5050
$response->setStatusCode(Response::HTTP_NOT_FOUND);
5151
}
@@ -56,7 +56,7 @@
5656
$twig = new TwigWrapper(PMF_ROOT_DIR . '/assets/templates/');
5757
$twigTemplate = $twig->loadTemplate('./show.twig');
5858

59-
if (!is_null($selectedCategoryId) && isset($category->categoryName[$selectedCategoryId])) {
59+
if (!is_null($selectedCategoryId) && isset($category->getCategoryName($selectedCategoryId))) {
6060
$faqSession->userTracking('show_category', $selectedCategoryId);
6161

6262
$categoryData = $category->getCategoryData($selectedCategoryId);
@@ -96,7 +96,7 @@
9696
$sids,
9797
$categoryData->getParentId()
9898
);
99-
$text = $category->categoryName[$categoryData->getParentId()]['name'] ?? Translation::get('msgCategoryUp');
99+
$text = $category->getCategoryName($categoryData->getParentId()) ?? Translation::get('msgCategoryUp');
100100

101101
$link = new Link($url, $faqConfig);
102102
$link->itemTitle = $text;

0 commit comments

Comments
 (0)