Skip to content

Commit

Permalink
fixed category path retrieval, closes #3815
Browse files Browse the repository at this point in the history
  • Loading branch information
Guite committed Oct 2, 2017
1 parent 8d45af0 commit e661d1c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-1.5.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ CHANGELOG - ZIKULA 1.5.x
- Fixed broken search result url handling for new-style modules.
- Improved detection and naming of available PDO drivers (#3785).
- Use uncached JS routes (#3807).
- Fixed issue with category retrieval by path (#3815).

- Vendor updates:
- ?
Expand Down
19 changes: 19 additions & 0 deletions src/system/CategoriesModule/Api/CategoryApi.php
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,25 @@ public function getCategoryByPath($apath, $pathField = 'path', $sort = '', $incl
$values = [];
foreach ($apath as $path) {
$parts = explode('/', $path);

if ($pathField == 'path') {
$parts = array_values(array_filter($parts));

if (!empty($parts)) {
$last = count($parts) - 1;

foreach ($parts as $part_key => $part_value) {
$criteria = [];
if ($part_key == 0) {
$criteria = ['name' => $parts[$part_key]];
} elseif ($part_key != $last) {
$criteria = ['name' => $parts[$part_key], 'parent' => $parent];
}
$parent = $repo->findOneBy($criteria)->getId();
}
}
}

$values[] = array_pop($parts);
}
if (count($values) > 1) {
Expand Down

0 comments on commit e661d1c

Please sign in to comment.