11
11
use Alexecus \Spawner \Managers \OperationsManager ;
12
12
use Alexecus \Spawner \Managers \ValidatorsManager ;
13
13
use Alexecus \Spawner \Managers \InputsManager ;
14
+ use Alexecus \Spawner \Managers \NormalizerManager ;
14
15
15
16
use Alexecus \Spawner \Operations ;
16
17
use Alexecus \Spawner \Validators ;
17
18
use Alexecus \Spawner \Input ;
19
+ use Alexecus \Spawner \Normalizers ;
18
20
19
21
/**
20
22
* Class that bootstraps the generator application
@@ -36,6 +38,11 @@ class Application
36
38
*/
37
39
private $ inputs ;
38
40
41
+ /**
42
+ * @var NormalizerManager
43
+ */
44
+ private $ normalizers ;
45
+
39
46
/**
40
47
* Stores the command
41
48
*
@@ -53,6 +60,7 @@ public function __construct($name = 'Spawner', $version = '1.0')
53
60
$ this ->operations = Container::resolve (OperationsManager::class);
54
61
$ this ->validators = Container::resolve (ValidatorsManager::class);
55
62
$ this ->inputs = Container::resolve (InputsManager::class);
63
+ $ this ->normalizers = Container::resolve (NormalizerManager::class);
56
64
57
65
$ this ->init ();
58
66
}
@@ -69,13 +77,16 @@ public function init()
69
77
$ this ->addOperation ('copy ' , Operations \Copy::class);
70
78
$ this ->addOperation ('notify ' , Operations \Notify::class);
71
79
$ this ->addOperation ('template ' , Operations \Template::class);
80
+ $ this ->addOperation ('yaml ' , Operations \Yaml::class);
72
81
73
82
$ this ->addValidator ('empty ' , Validators \EmptyValidator::class);
74
83
$ this ->addValidator ('starts_with ' , Validators \StartsWithValidator::class);
75
84
$ this ->addValidator ('ends_with ' , Validators \EndsWithValidator::class);
76
85
77
86
$ this ->addInput ('ask ' , Input \AskInput::class);
78
87
$ this ->addInput ('confirm ' , Input \ConfirmInput::class);
88
+
89
+ $ this ->addNormalizer ('snake_case ' , Normalizers \SnakeCase::class);
79
90
}
80
91
81
92
/**
@@ -135,6 +146,7 @@ public function run()
135
146
$ command ->setOperations ($ this ->operations );
136
147
$ command ->setValidators ($ this ->validators );
137
148
$ command ->setInputs ($ this ->inputs );
149
+ $ command ->setNormalizers ($ this ->normalizers );
138
150
139
151
$ this ->console ->add ($ command );
140
152
}
@@ -179,4 +191,15 @@ public function addInput($id, $class)
179
191
{
180
192
$ this ->inputs ->setInput ($ id , Container::resolve ($ class ));
181
193
}
194
+
195
+ /**
196
+ * Adds a new normalizer class
197
+ *
198
+ * @param string $id The instances ID
199
+ * @param string $class The fully qualified class name
200
+ */
201
+ public function addNormalizer ($ id , $ class )
202
+ {
203
+ $ this ->normalizers ->setNormalizer ($ id , Container::resolve ($ class ));
204
+ }
182
205
}
0 commit comments