Skip to content

Commit

Permalink
Fix CS
Browse files Browse the repository at this point in the history
  • Loading branch information
Hlavtox committed Sep 6, 2024
1 parent dfd6881 commit 43246f4
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions ps_categorytree.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ private function getCategories($category)
$groups = Customer::getGroupsStatic((int) $this->context->customer->id);
$sqlFilter = $maxdepth ? 'AND c.`level_depth` <= ' . (int) $maxdepth : '';
$orderBy = ' ORDER BY c.`level_depth` ASC, ' . (Configuration::get('BLOCK_CATEG_SORT') ? 'cl.`name`' : 'category_shop.`position`') . ' ' . (Configuration::get('BLOCK_CATEG_SORT_WAY') ? 'DESC' : 'ASC');

// Retrieve them using the built in method
$categories = Category::getNestedCategories($category->id, $this->context->language->id, true, $groups, true, $sqlFilter, $orderBy);

Expand All @@ -147,7 +147,7 @@ private function getCategories($category)
foreach ($categories as $k => $v) {
$categories[$k] = $this->formatCategory($v, $idsOfCategoriesInPath);
}

return array_shift($categories);
}

Expand Down Expand Up @@ -300,7 +300,8 @@ public function getWidgetVariables($hookName = null, array $configuration = [])
* In case of product controller, it's either the default category of the product, or the category the customer
* came from. This is resolved by the ProductController.
*/
private function getCurrentCategory() {
private function getCurrentCategory()
{
/*
* We check several things:
* If the controller has the method
Expand All @@ -323,7 +324,8 @@ private function getCurrentCategory() {
* Tries to get a parent of the current category.
* If we are already on the top of the tree, it will return the input.
*/
private function tryToGetParentCategoryIfAvailable($category) {
private function tryToGetParentCategoryIfAvailable($category)
{
// If we are already on the top of the tree, nothing to do here
if ($category->is_root_category || !$category->id_parent) {
return $category;
Expand All @@ -332,14 +334,16 @@ private function tryToGetParentCategoryIfAvailable($category) {
return new Category($category->id_parent, $this->context->language->id);
}

private function getIdsOfCategoriesInPathToCurrentCategory() {
private function getIdsOfCategoriesInPathToCurrentCategory()
{
// Call built in method to retrieve all parents, including the current category
$categories = $this->getCurrentCategory()->getParentsCategories();

return array_column($categories, 'id_category');
}

private function getHomeCategory() {
private function getHomeCategory()
{
return new Category((int) Configuration::get('PS_HOME_CATEGORY'), $this->context->language->id);
}
}

0 comments on commit 43246f4

Please sign in to comment.