diff --git a/config/services.yml b/config/services.yml index 3b1839a..88f9066 100644 --- a/config/services.yml +++ b/config/services.yml @@ -33,6 +33,7 @@ services: arguments: - '@database_connection' - '@contao.twig.filesystem_loader' + - '%kernel.project_dir%' - '%kernel.project_dir%/themes' Richardhj\ContaoThemeFramework\Command\CreateThemeCommand: diff --git a/src/DependencyInjection/RichardhjContaoThemeFrameworkExtension.php b/src/DependencyInjection/RichardhjContaoThemeFrameworkExtension.php index 5db8002..f76f860 100644 --- a/src/DependencyInjection/RichardhjContaoThemeFrameworkExtension.php +++ b/src/DependencyInjection/RichardhjContaoThemeFrameworkExtension.php @@ -35,6 +35,6 @@ public function load(array $configs, ContainerBuilder $container) } $config = $this->processConfiguration(new Configuration(), $configs); - $container->getDefinition(ThemeMigration::class)->replaceArgument(2, $config['themes_path']); + $container->getDefinition(ThemeMigration::class)->replaceArgument(3, $config['themes_path']); } } diff --git a/src/Migration/ThemeMigration.php b/src/Migration/ThemeMigration.php index cca2db5..9f6ebec 100644 --- a/src/Migration/ThemeMigration.php +++ b/src/Migration/ThemeMigration.php @@ -31,12 +31,14 @@ class ThemeMigration implements MigrationInterface { private Connection $connection; private ContaoFilesystemLoader $filesystemLoader; + private string $rootDir; private string $themesPath; - public function __construct(Connection $connection, ContaoFilesystemLoader $filesystemLoader, string $themesPath) + public function __construct(Connection $connection, ContaoFilesystemLoader $filesystemLoader, string $rootDir, string $themesPath) { $this->connection = $connection; $this->filesystemLoader = $filesystemLoader; + $this->rootDir = $rootDir; $this->themesPath = $themesPath; } @@ -178,11 +180,13 @@ 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('themes/%s/templates', $themeName), + 'templates' => sprintf('%s/%s/templates', $themePath, $themeName), 'manifestHash' => $manifestHash, ];