@@ -10,8 +10,8 @@ class MapCommand extends AbstractCommand
10
10
* @var string
11
11
*/
12
12
protected $ signature = 'hunt:map
13
- {action : Mapping action to perform (add or remove) }
14
- {model : Name or comma separated names of the model(s) to initialize } ' ;
13
+ {model : Name or comma separated names of the model(s) to initialize }
14
+ {--l|locales= : Single or comma separated locales } ' ;
15
15
16
16
/**
17
17
* The console command description.
@@ -25,21 +25,23 @@ class MapCommand extends AbstractCommand
25
25
*/
26
26
public function handle ()
27
27
{
28
- $ action = $ this ->getActionArgument (['add ' , 'remove ' ]);
28
+ // Process any locales
29
+ if (empty ($ locales = $ this ->getLocales ()) === false ) {
30
+ foreach ($ locales as $ locale ) {
31
+ $ this ->setSystemLocale ($ locale );
29
32
30
- foreach ($ this ->getModelArgument () as $ model ) {
31
- if ($ model = $ this ->validateModel ("\\App \\{$ model }" )) {
32
- $ this ->$ action ($ model );
33
+ $ this ->processModels ('add ' );
33
34
}
34
35
}
36
+ else {
37
+ $ this ->processModels ('add ' );
38
+ }
35
39
}
36
40
37
41
/**
38
42
* Add ElasticSearch model mapping.
39
43
*
40
44
* @param string $model
41
- *
42
- * @return bool
43
45
*/
44
46
protected function add ($ model )
45
47
{
@@ -53,24 +55,4 @@ protected function add($model)
53
55
54
56
$ this ->output ->writeln ("<info>success</info> " );
55
57
}
56
-
57
- /**
58
- * Remove ElasticSearch model mapping.
59
- *
60
- * @param string $model
61
- *
62
- * @return bool
63
- */
64
- protected function remove ($ model )
65
- {
66
- if ($ this ->hunter ->typeExists ($ model ) === false ) {
67
- return $ this ->error ("[ {$ model }] not mapped " );
68
- }
69
-
70
- $ this ->output ->write ("Removing [ {$ model }] map... " );
71
-
72
- $ this ->hunter ->deleteMapping ($ model );
73
-
74
- $ this ->output ->writeln ("<info>success</info> " );
75
- }
76
58
}
0 commit comments