Inital commit

This commit is contained in:
2020-11-19 15:36:28 +01:00
parent 71f32f83d3
commit 66ce4ee218
18077 changed files with 2166122 additions and 35184 deletions

View File

@@ -2,6 +2,7 @@
namespace Thelia\Model;
use Propel\Runtime\ActiveQuery\Criteria;
use Thelia\Model\Base\FolderQuery as BaseFolderQuery;
/**
@@ -31,7 +32,7 @@ class FolderQuery extends BaseFolderQuery
/**
* find all contents for a given folder.
*
* @param $folderId the folder id or an array of id
* @param int $folderId the folder id or an array of id
* @param int $depth max depth you want to search
* @param int $currentPosition don't change this param, it is used for recursion
* @return \Thelia\Model\Folder[]
@@ -47,7 +48,9 @@ class FolderQuery extends BaseFolderQuery
} else {
$currentPosition++;
if($depth == $currentPosition && $depth != 0) return;
if ($depth == $currentPosition && $depth != 0) {
return[];
}
$categories = self::create()
->filterByParent($folderId)
@@ -61,4 +64,34 @@ class FolderQuery extends BaseFolderQuery
return $result;
}
} // FolderQuery
/**
* Return all folder IDs of a folder tree, starting at $folderId, up to a depth of $depth
*
* @param int|int[] $folderId the folder id or an array of folder ids
* @param int $depth max tree traversal depth
* @return int[]
* @since 2.3
*/
public static function getFolderTreeIds($folderId, $depth = 1)
{
$result = is_array($folderId) ? $folderId : [ $folderId ];
if ($depth > 1) {
$folders = self::create()
->filterByParent($folderId, Criteria::IN)
->withColumn('id')
->find();
foreach ($folders as $folder) {
$result = array_merge(
$result,
self::getFolderTreeIds($folder->getId(), $depth - 1)
);
}
}
return $result;
}
}
// FolderQuery