Skip to content

Commit

Permalink
Added findThemesInPath method
Browse files Browse the repository at this point in the history
  • Loading branch information
jaxwilko committed Jan 4, 2025
1 parent bb953e9 commit 43acf5c
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions modules/cms/classes/ThemeManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,21 @@

namespace Cms\Classes;

use FilesystemIterator;
use Illuminate\Console\View\Components\Error;
use Illuminate\Console\View\Components\Info;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Artisan;
use RecursiveDirectoryIterator;
use RecursiveIteratorIterator;
use System\Classes\Extensions\ExtensionManager;
use System\Classes\Extensions\ExtensionManagerInterface;
use System\Classes\Extensions\Source\ExtensionSource;
use Winter\Storm\Foundation\Extension\WinterExtension;
use System\Models\Parameter;
use Winter\Storm\Exception\ApplicationException;
use Winter\Storm\Foundation\Extension\WinterExtension;
use Winter\Storm\Packager\Composer;
use Winter\Storm\Support\Facades\File;
use Winter\Storm\Support\Facades\Yaml;

/**
* Theme manager
Expand Down Expand Up @@ -223,6 +226,27 @@ public function availableUpdates(WinterExtension|string|null $extension = null):
return $updates;
}

public function findThemesInPath(string $path): array
{
$themeFiles = [];

$iterator = new RecursiveIteratorIterator(
new RecursiveDirectoryIterator($path, FilesystemIterator::SKIP_DOTS),
RecursiveIteratorIterator::SELF_FIRST
);

foreach ($iterator as $file) {
if ($file->isFile() && $file->getFilename() === 'theme.yaml') {
$config = Yaml::parseFile($file->getRealPath());
if (isset($config['name'])) {
$themeFiles[$config['name']] = $file->getPathname();
}
}
}

return $themeFiles;
}

/**
* @throws ApplicationException
*/
Expand Down

0 comments on commit 43acf5c

Please sign in to comment.