mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-07-10 18:34:32 +02:00
Started to implement a very basic builtin footprints gallery tool
This commit is contained in:
parent
39d4f06c12
commit
ddd8a66024
3 changed files with 96 additions and 0 deletions
|
@ -42,6 +42,39 @@ class BuiltinAttachmentsFinder
|
|||
$this->cache = $cache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an array with all builtin footprints, grouped by their folders
|
||||
* The array have the form of: [
|
||||
* '/path/to/folder' => [
|
||||
* '%FOOTPRINTS%/path/to/folder/file1.png',
|
||||
* '%FOOTPRINTS%/path/to/folder/file2.png',
|
||||
* ]
|
||||
* @return array
|
||||
*/
|
||||
public function getListOfFootprintsGroupedByFolder(): array
|
||||
{
|
||||
$finder = new Finder();
|
||||
//We search only files
|
||||
$finder->files();
|
||||
$finder->in($this->pathResolver->getFootprintsPath());
|
||||
|
||||
$output = [];
|
||||
|
||||
foreach($finder as $file) {
|
||||
$folder = $file->getRelativePath();
|
||||
//Normalize path (replace \ with /)
|
||||
$folder = str_replace('\\', '/', $folder);
|
||||
|
||||
if(!isset($output[$folder])) {
|
||||
$output[$folder] = [];
|
||||
}
|
||||
//Add file to group
|
||||
$output[$folder][] = $this->pathResolver->realPathToPlaceholder($file->getPathname());
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a list of all builtin ressources.
|
||||
* The array is a list of the relative filenames using the %PLACEHOLDERS%.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue