Skip to content

Commit

Permalink
GH-224 Allow to specify root dir for lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
mdziekon committed Jul 1, 2022
1 parent 3b30ce3 commit 982f8ba
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions modules/settings/utils/helpers/getAvailableSkins.helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,23 +2,29 @@

namespace UniEngine\Engine\Modules\Settings\Utils\Helpers;

function getAvailableSkins() {
/**
* @param array $params
* @param string $params['rootDir'] (default: "./")
*/
function getAvailableSkins($params = []) {
$rootDir = !empty($params['rootDir']) ? $params['rootDir'] : "./";

$knownSkinNames = [
'xnova' => 'XNova',
'epicblue' => 'EpicBlue Fresh',
'epicblue_old' => 'EpicBlue Standard',
];

$skinsDir = 'skins';
$skinsDirEntries = scandir("./{$skinsDir}/");
$skinsDirEntries = scandir("{$rootDir}/{$skinsDir}/");
$skinsDirEntries = !empty($skinsDirEntries) ? $skinsDirEntries : [];

$availableSkins = [];

foreach ($skinsDirEntries as $skinDirEntry) {
if (
strstr($skinDirEntry, '.') !== false ||
!is_dir("./skins/{$skinDirEntry}")
!is_dir("{$rootDir}/skins/{$skinDirEntry}")
) {
continue;
}
Expand Down

0 comments on commit 982f8ba

Please sign in to comment.