3
3
namespace Hexadog \ThemesManager \Console \Generators ;
4
4
5
5
use Exception ;
6
- use Hexadog \ThemesManager \Console \Commands \Traits \BlockMessage ;
7
- use Hexadog \ThemesManager \Console \Commands \Traits \SectionMessage ;
8
- use Hexadog \ThemesManager \Facades \ThemesManager ;
6
+ use Illuminate \Support \Arr ;
7
+ use Illuminate \Support \Str ;
9
8
use Illuminate \Console \Command ;
10
9
use Illuminate \Config \Repository ;
11
10
use Illuminate \Filesystem \Filesystem ;
12
- use Illuminate \Support \Arr ;
13
- use Illuminate \Support \Str ;
11
+ use Hexadog \ThemesManager \Facades \ThemesManager ;
12
+ use Hexadog \ThemesManager \Console \Commands \Traits \BlockMessage ;
13
+ use Hexadog \ThemesManager \Console \Commands \Traits \SectionMessage ;
14
14
15
15
class MakeTheme extends Command
16
16
{
@@ -94,6 +94,9 @@ public function handle()
94
94
}
95
95
}
96
96
97
+ /**
98
+ * Validate theme name provided.
99
+ */
97
100
protected function validateName ()
98
101
{
99
102
$ this ->askName ();
@@ -128,6 +131,11 @@ protected function validateName()
128
131
return true ;
129
132
}
130
133
134
+ /**
135
+ * Generate Theme structure in target directory.
136
+ *
137
+ * @return void
138
+ */
131
139
private function generateTheme ()
132
140
{
133
141
$ this ->sectionMessage ('Files generation ' , 'start files generation process... ' );
@@ -161,12 +169,20 @@ private function generateTheme()
161
169
}
162
170
}
163
171
172
+ /**
173
+ * Replace placeholders in generated file.
174
+ *
175
+ * @param \Symfony\Component\Finder\SplFileInfo $file
176
+ *
177
+ * @return string
178
+ */
164
179
protected function replacePlaceholders ($ file )
165
180
{
166
181
$ this ->sectionMessage ('File generation ' , "{$ file ->getPathName ()}" );
167
182
168
183
$ find = [
169
- 'DummyAuthor ' ,
184
+ 'DummyAuthorName ' ,
185
+ 'DummyAuthorEmail ' ,
170
186
'DummyDescription ' ,
171
187
'DummyName ' ,
172
188
'DummyParent ' ,
@@ -175,8 +191,9 @@ protected function replacePlaceholders($file)
175
191
];
176
192
177
193
$ replace = [
178
- Str::title (Arr::get ($ this ->theme , 'author ' , '' )),
179
- Str::title (Arr::get ($ this ->theme , 'description ' , '' )),
194
+ Str::title (Arr::get ($ this ->theme , 'author-name ' , '' )),
195
+ Arr::get ($ this ->theme , 'author-email ' , '' ),
196
+ Arr::get ($ this ->theme , 'description ' , '' ),
180
197
Arr::get ($ this ->theme , 'name ' , '' ),
181
198
Arr::get ($ this ->theme , 'parent ' , '' ),
182
199
Arr::get ($ this ->theme , 'vendor ' , '' ),
@@ -186,16 +203,34 @@ protected function replacePlaceholders($file)
186
203
return str_replace ($ find , $ replace , $ file ->getContents ());
187
204
}
188
205
206
+ /**
207
+ * Ask for theme author information.
208
+ * Notice: if value is set in themes-manager.composer.author.name and themes-manager.composer.author.email config value
209
+ * then this value will be used.
210
+ *
211
+ * @return void
212
+ */
189
213
protected function askAuthor ()
190
214
{
191
- $ this ->config ['author ' ] = $ this ->ask ('Author name ' );
215
+ $ this ->theme ['author-name ' ] = $ this ->config ->get ('themes-manager.composer.author.name ' ) ?? $ this ->ask ('Author name ' );
216
+ $ this ->theme ['author-email ' ] = $ this ->config ->get ('themes-manager.composer.author.email ' ) ?? $ this ->ask ('Author email ' );
192
217
}
193
218
219
+ /**
220
+ * Ask for theme description.
221
+ *
222
+ * @return void
223
+ */
194
224
protected function askDescription ()
195
225
{
196
- $ this ->config ['description ' ] = $ this ->ask ('Description ' );
226
+ $ this ->theme ['description ' ] = $ this ->ask ('Description ' );
197
227
}
198
228
229
+ /**
230
+ * Ask for theme name.
231
+ *
232
+ * @return void
233
+ */
199
234
protected function askName ()
200
235
{
201
236
while (empty (Arr::get ($ this ->theme , 'name ' , null ))) {
@@ -209,19 +244,32 @@ protected function askName()
209
244
}
210
245
}
211
246
247
+ /**
248
+ * Ask for parent theme name.
249
+ */
212
250
protected function askParent ()
213
251
{
214
252
if ($ this ->confirm ('Is it a child theme? ' )) {
215
253
$ this ->theme ['parent ' ] = $ this ->ask ('Parent theme name ' );
216
- $ this ->theme ['parent ' ] = strtolower ($ this ->theme ['parent ' ]);
254
+ $ this ->theme ['parent ' ] = mb_strtolower ($ this ->theme ['parent ' ]);
217
255
}
218
256
}
219
257
258
+ /**
259
+ * Ask for theme vendor.
260
+ * Notice: if value is set in themes-manager.composer.vendor config value
261
+ * then this value will be used.
262
+ *
263
+ * @return void
264
+ */
220
265
protected function askVendor ()
221
266
{
222
- $ this ->theme ['vendor ' ] = mb_strtolower ($ this ->ask ('Vendor name ' ));
267
+ $ this ->theme ['vendor ' ] = mb_strtolower ($ this ->config -> get ( ' themes-manager.composer.vendor ' ) ?? $ this -> ask ('Vendor name ' ));
223
268
}
224
269
270
+ /**
271
+ * Ask for theme version.
272
+ */
225
273
protected function askVersion ()
226
274
{
227
275
$ this ->theme ['version ' ] = $ this ->ask ('Version number ' );
0 commit comments