Skip to content

Commit

Permalink
themes_path is relative now
Browse files Browse the repository at this point in the history
  • Loading branch information
richardhj committed Sep 7, 2024
1 parent 6a20bd5 commit 27ae99f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
3 changes: 2 additions & 1 deletion src/DependencyInjection/Configuration.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ public function getConfigTreeBuilder(): TreeBuilder
$treeBuilder->getRootNode()
->children()
->scalarNode('themes_path')
->defaultValue('%kernel.project_dir%/themes')
->defaultValue('themes')
->info('The path to the themes directory, relative to the root dir.')
->end()
->end()
;
Expand Down
13 changes: 7 additions & 6 deletions src/Migration/ThemeMigration.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Config\Definition\Processor;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderResolver;
use Symfony\Component\Filesystem\Path;
use Symfony\Component\Finder\Finder;

/**
Expand Down Expand Up @@ -49,13 +50,14 @@ public function getName(): string

public function shouldRun(): bool
{
if (!file_exists($this->themesPath)) {
$themesPath = Path::join($this->rootDir, $this->themesPath);
if (!file_exists($themesPath)) {
return false;
}

$manifests = (new Finder())
->files()
->in($this->themesPath)
->in($themesPath)
->name(['theme.yml', 'theme.yaml'])
->getIterator()
;
Expand Down Expand Up @@ -88,9 +90,10 @@ public function shouldRun(): bool

public function run(): MigrationResult
{
$themesPath = Path::join($this->rootDir, $this->themesPath);
$manifests = (new Finder())
->files()
->in($this->themesPath)
->in($themesPath)
->name(['theme.yml', 'theme.yaml'])
->getIterator()
;
Expand Down Expand Up @@ -180,13 +183,11 @@ private function persistTheme($id, $name, string $themeName, string $manifestHas
{
$themeId = $id ?? null;

$themePath = str_replace($this->rootDir.'/', '', $this->themesPath);

$data = [
'name' => $name,
'alias' => $themeName,
'tstamp' => time(),
'templates' => sprintf('%s/%s/templates', $themePath, $themeName),
'templates' => sprintf('%s/%s/templates', $this->themesPath, $themeName),
'manifestHash' => $manifestHash,
];

Expand Down

0 comments on commit 27ae99f

Please sign in to comment.