Open lbucche opened 3 years ago
I've tried on linux system it works. So probably something related to the windows\Xampp platform.
@boehsermoe @lbucche maybe something with DIRECTORY_SEPERATOR
So the theme folder is not even recognized? So it might me a problem here https://github.com/luyadev/luya-module-cms/blob/master/src/admin/importers/ThemeImporter.php - as there something known regarding windows @boehsermoe ?
@lbucche please try it again with v1.7.1 fix (https://github.com/luyadev/luya/releases/tag/1.7.1) Does it fixed your problem?
@boehsermoe i think this (https://github.com/luyadev/luya/pull/2058/files) will not fix the problem. this just fixes the problem when you use the theme create command on a windows computer i would say.
No with v.1.7.1 fix I get this.
luya theme/create
Enter the name (lower case) of the theme you like to generate: mytheme Enter the theme location where to generate (as path alias e.g. app, ): [app] Exception 'yii\base\InvalidArgumentException' with message 'Invalid path alias: @app\themes\mytheme'
in C:\MyGitProject\testthemes\vendor\yiisoft\yii2\BaseYii.php:154
Stack trace:
Reverting to previous version the "luya theme/create" command works again as normal, and I managed to create a theme in app contest as usual. Investigating the issue deeper I found that the problem on wndows platform is in the ThemeImporter in the getThemeDefinitions function. On windows if you var_dump the themes config at row 182 in luya-core\theme\ThemManager.php you find this paths:
string(48) "vendor\luyadev/luya-themes\themes\escapeVelocity" string(39) "vendor\luyadev/luya-themes\themes\forty" string(40) "vendor\luyadev/luya-themes\themes\strata"
So there's a simple slash/backslash problem. I tried this simple workaround and I successfully import the themes.
protected function getThemeDefinitions() { $themeDefinitions = [];
if (file_exists(Yii::getAlias('@app/themes'))) {
foreach (glob(Yii::getAlias('@app/themes/*')) as $dirPath) {
$themeDefinitions[] = "@app/themes/" . basename($dirPath);
}
}
foreach (Yii::$app->getPackageInstaller()->getConfigs() as $config) {
/** @var PackageConfig $config */
foreach ($config->themes as $theme) {
//-- simple patch -----
$normalization["\\"]="/";
$theme = strtr($theme,$normalization);
//-- simple patch -----
if (strpos($theme, '@') === 0 || strpos($theme, '/') === 0) {
$themeDefinitions[] = $theme;
} else {
$themeDefinitions[] = preg_replace('#^vendor/#', '@vendor/', $theme);
}
}
}
return $themeDefinitions;
}
Hope this helps.
Thank you @lbucche. Yes that was my guess as well as the importer handles the paths wrong.
@boehsermoe should we move that problem into the LUYA core issue tracker?
What steps will reproduce the problem?
composer create-project luyadev/luya-kickstarter:^1.0 changed the composer.json to get new releases and added package with themes in this way: [...] "require": { "luyadev/luya-core": "^1.0", "luyadev/luya-module-admin": "^3.0", "luyadev/luya-module-cms": "^3.0", "luyadev/luya-bootstrap3": "^1.0", "luyadev/luya-generic": "^1.0", "luyadev/luya-themes": "*@dev" }, composer update luya migrate luya import
LUYA import command (based on LUYA 1.7.0)
luya\cms\admin\importers\ThemeImporter: ╔═════╤════════════════════════════════════════╗ ║ Key │ Value ║ ╟─────┼────────────────────────────────────────╢ ║ 0 │ Theme importer finished with 0 themes. ║ ╚═════╧════════════════════════════════════════╝
What is the expected result?
new themes added to cms and listed in admin
What do you get instead? (A Screenshot can help us a lot!)
No new themes added
If you manually create a new theme in the app contest it works perfectly (luya theme/create) If you create a new composer package/module-theme, you add it in the config file, and then you create the theme using the wizard, it creates correctly the new theme in package folder, but when you import theme, it isn't present.
So it seems the the ThemeImporter can't find themes that are in "external" packages.
Any idea?
LUYA Check ouput (run this script and post the result: luyacheck.php)
Additional infos