@@ -7,7 +7,6 @@ |
||
7 | 7 | use luya\theme\ThemeConfig; |
8 | 8 | use Yii; |
9 | 9 | use yii\helpers\Console; |
10 | -use yii\helpers\Inflector; |
|
11 | 10 | |
12 | 11 | /** |
13 | 12 | * Command to create a new LUYA theme. |
@@ -38,7 +38,7 @@ discard block |
||
38 | 38 | $themeConfig->parentTheme = $this->prompt("Enter the base path (e.g. `@app/themes/blank`) of the parent theme:", |
39 | 39 | [ |
40 | 40 | 'default' => '@app/themes/blank', |
41 | - 'validator' => function ($input, &$error) { |
|
41 | + 'validator' => function($input, &$error) { |
|
42 | 42 | if (preg_match('/^[a-z]+$/', $input) === false) { |
43 | 43 | $error = 'The theme name must be only letter chars!'; |
44 | 44 | return false; |
@@ -77,7 +77,7 @@ discard block |
||
77 | 77 | |
78 | 78 | $availableModules = implode(', ', array_column(Yii::$app->getFrontendModules(), 'id')); |
79 | 79 | $themeLocation = $this->prompt("Enter the theme location where to generate (as path alias e.g. app, $availableModules):", ['default' => 'app']); |
80 | - $themeLocation = '@' . ltrim($themeLocation, '@'); |
|
80 | + $themeLocation = '@'.ltrim($themeLocation, '@'); |
|
81 | 81 | |
82 | 82 | preg_match("#^@[A-z]+#", $themeLocation, $newThemeLocation); |
83 | 83 | if ($newThemeLocation[0] !== $themeLocation) { |
@@ -88,15 +88,15 @@ discard block |
||
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | - $basePath = $themeLocation . DIRECTORY_SEPARATOR . 'themes' . DIRECTORY_SEPARATOR . $themeName; |
|
91 | + $basePath = $themeLocation.DIRECTORY_SEPARATOR.'themes'.DIRECTORY_SEPARATOR.$themeName; |
|
92 | 92 | $themeFolder = Yii::getAlias($basePath); |
93 | 93 | |
94 | 94 | if (file_exists($themeFolder)) { |
95 | - return $this->outputError("The folder " . $themeFolder . " exists already."); |
|
95 | + return $this->outputError("The folder ".$themeFolder." exists already."); |
|
96 | 96 | } |
97 | 97 | |
98 | - $this->outputInfo("Theme path alias: " . $basePath); |
|
99 | - $this->outputInfo("Theme real path: " . $themeFolder); |
|
98 | + $this->outputInfo("Theme path alias: ".$basePath); |
|
99 | + $this->outputInfo("Theme real path: ".$themeFolder); |
|
100 | 100 | if (!$this->confirm("Do you want continue?")) { |
101 | 101 | return $this->outputError('Abort by user.'); |
102 | 102 | } |
@@ -110,11 +110,11 @@ discard block |
||
110 | 110 | ]; |
111 | 111 | |
112 | 112 | foreach ($folders as $folder) { |
113 | - FileHelper::createDirectory($themeFolder . DIRECTORY_SEPARATOR . $folder); |
|
113 | + FileHelper::createDirectory($themeFolder.DIRECTORY_SEPARATOR.$folder); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | $contents = [ |
117 | - $themeFolder. DIRECTORY_SEPARATOR . 'theme.json' => $this->renderJson($basePath, $themeName), |
|
117 | + $themeFolder.DIRECTORY_SEPARATOR.'theme.json' => $this->renderJson($basePath, $themeName), |
|
118 | 118 | ]; |
119 | 119 | |
120 | 120 | foreach ($contents as $fileName => $content) { |
@@ -142,6 +142,9 @@ |
||
142 | 142 | } |
143 | 143 | |
144 | 144 | |
145 | + /** |
|
146 | + * @param string $basePath |
|
147 | + */ |
|
145 | 148 | public function getThemeByBasePath($basePath) |
146 | 149 | { |
147 | 150 | $themes = $this->getThemes(); |
@@ -47,10 +47,10 @@ discard block |
||
47 | 47 | $dir = Yii::getAlias($basePath); |
48 | 48 | |
49 | 49 | if (!is_dir($dir) || !is_readable($dir)) { |
50 | - throw new Exception('Theme directory not exists or readable: ' . $dir); |
|
50 | + throw new Exception('Theme directory not exists or readable: '.$dir); |
|
51 | 51 | } |
52 | 52 | |
53 | - $themeFile = $dir . '/theme.json'; |
|
53 | + $themeFile = $dir.'/theme.json'; |
|
54 | 54 | if (file_exists($themeFile)) { |
55 | 55 | $config = Json::decode(file_get_contents($themeFile)) ?: []; |
56 | 56 | } else { |
@@ -130,7 +130,7 @@ discard block |
||
130 | 130 | $themeDefinitions = []; |
131 | 131 | |
132 | 132 | foreach (scandir(Yii::getAlias('@app/themes')) as $dirPath) { |
133 | - $themeDefinitions = array_merge($themeDefinitions, "@app/themes/" , basename($dirPath)); |
|
133 | + $themeDefinitions = array_merge($themeDefinitions, "@app/themes/", basename($dirPath)); |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | foreach (Yii::$app->getPackageInstaller()->getConfigs() as $config) { |
@@ -86,6 +86,6 @@ |
||
86 | 86 | |
87 | 87 | public function getViewPath(): string |
88 | 88 | { |
89 | - return $this->getBasePath() . '/views'; |
|
89 | + return $this->getBasePath().'/views'; |
|
90 | 90 | } |
91 | 91 | } |
92 | 92 | \ No newline at end of file |