-
-
Notifications
You must be signed in to change notification settings - Fork 201
/
Copy pathCreateFormWidget.php
71 lines (61 loc) · 1.88 KB
/
CreateFormWidget.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
<?php namespace Backend\Console;
use Winter\Storm\Scaffold\GeneratorCommand;
class CreateFormWidget extends GeneratorCommand
{
/**
* The default command name for lazy loading.
*
* @var string|null
*/
protected static $defaultName = 'create:formwidget';
/**
* The name and signature of this command.
*
* @var string
*/
protected $signature = 'create:formwidget
{plugin : The name of the plugin. <info>(eg: Winter.Blog)</info>}
{widget : The name of the form widget to generate. <info>(eg: PostList)</info>}
{--force : Overwrite existing files with generated files.}';
/**
* The console command description.
*
* @var string
*/
protected $description = 'Creates a new form widget.';
/**
* The type of class being generated.
*
* @var string
*/
protected $type = 'FormWidget';
/**
* A mapping of stub to generated file.
*
* @var array
*/
protected $stubs = [
'scaffold/formwidget/formwidget.stub' => 'formwidgets/{{studly_name}}.php',
'scaffold/formwidget/partial.stub' => 'formwidgets/{{lower_name}}/partials/_{{lower_name}}.htm',
'scaffold/formwidget/stylesheet.stub' => 'formwidgets/{{lower_name}}/assets/css/{{lower_name}}.css',
'scaffold/formwidget/javascript.stub' => 'formwidgets/{{lower_name}}/assets/js/{{lower_name}}.js',
];
/**
* Prepare variables for stubs.
*
* return @array
*/
protected function prepareVars()
{
$pluginCode = $this->argument('plugin');
$parts = explode('.', $pluginCode);
$plugin = array_pop($parts);
$author = array_pop($parts);
$widget = $this->argument('widget');
return [
'name' => $widget,
'author' => $author,
'plugin' => $plugin
];
}
}