Skip to content

Commit 7d8b58a

Browse files
hjuarez20enzolutions
authored andcommitted
[generators] Change the parameters as array (#51)
1 parent 215a69f commit 7d8b58a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+585
-803
lines changed

config/translations/en/generate.metabox.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ questions:
3131
placeholder: 'Enter field placeholder'
3232
default-value: 'Enter field default value'
3333
src_image: 'Enter the image path'
34-
metabox-add-another: 'Do you want to add another item metabox'
34+
metabox-items-add-another: 'Do you want to add another item metabox'
3535
multiple-label: 'Enter the label for option for '
3636
multiple-value: 'Enter the value for option for '
3737
multiple-options-add: 'Do you want to add another option for %option%'

config/translations/en/generate.widget.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ questions:
2525
placeholder: 'Enter field placeholder'
2626
default-value: 'Enter field default value'
2727
src_image: 'Enter the image path'
28-
widget-add-another: 'Do you want to add another widget item'
28+
widget-items-add-another: 'Do you want to add another widget item'
2929
multiple-label: 'Enter the label for option for '
3030
multiple-value: 'Enter the value for option for '
3131
multiple-options-add: 'Do you want to add another option for %option%'

src/Command/Generate/CommandCommand.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,24 +114,27 @@ protected function execute(InputInterface $input, OutputInterface $output)
114114
$class = $this->validator->validateCommandName($input->getOption('class'));
115115
$name = $input->getOption('name');
116116
$services = $input->getOption('services');
117-
$yes = $input->hasOption('yes')?$input->getOption('yes'):false;
118117

119118
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
120119
if (!$this->confirmOperation()) {
121-
return;
120+
return 1;
122121
}
123122

124123
// @see use WP\Console\Command\Shared\ServicesTrait::buildServices
125124
$build_services = $this->buildServices($services);
126125

127126
$this->generator->generate(
128-
$plugin,
129-
$pluginNameSpace,
130-
$pluginCamelCaseMachineName,
131-
$name,
132-
$class,
133-
$build_services
127+
[
128+
'plugin' => $plugin,
129+
'class_name' => $class,
130+
'pluginNameSpace' => $pluginNameSpace,
131+
'pluginCamelCaseMachineName' => $pluginCamelCaseMachineName,
132+
'name' => $name,
133+
'services' => $build_services,
134+
]
134135
);
136+
137+
return 0;
135138
}
136139

137140
/**

src/Command/Generate/CronBaseCommand.php

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,18 +131,22 @@ protected function execute(InputInterface $input, OutputInterface $output)
131131

132132
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
133133
if (!$this->confirmOperation()) {
134-
return;
134+
return 1;
135135
}
136136

137137
$this->generator->generate(
138-
$plugin,
139-
$class_name,
140-
$timestamp,
141-
$recurrence,
142-
$hook_name,
143-
$hook_arguments,
144-
$this->cronType
138+
[
139+
'plugin' => $plugin,
140+
'class_name' => $class_name,
141+
'timestamp' => $timestamp,
142+
'recurrence' => $recurrence,
143+
'hook_name' => $hook_name,
144+
'hook_arguments' => $hook_arguments,
145+
'type' => $this->cronType,
146+
]
145147
);
148+
149+
return 0;
146150
}
147151

148152
/**

src/Command/Generate/DashboardWidgetsCommand.php

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
131131
{
132132
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
133133
if (!$this->confirmOperation()) {
134-
return;
134+
return 1;
135135
}
136136

137137
$plugin = $plugin = $this->validator->validatePluginName($input->getOption('plugin'));
@@ -144,15 +144,19 @@ protected function execute(InputInterface $input, OutputInterface $output)
144144
$text_domain = $input->getOption('text-domain');
145145

146146
$this->generator->generate(
147-
$plugin,
148-
$class_name,
149-
$id,
150-
$title,
151-
$render_function,
152-
$submission_function,
153-
$callback_arguments,
154-
$text_domain
147+
[
148+
'plugin' => $plugin,
149+
'class_name' => $class_name,
150+
'id' => $id,
151+
"title" => $title,
152+
"render_function" => $render_function,
153+
"submission_function" => $submission_function,
154+
"callback_arguments" => $callback_arguments,
155+
"text_domain" => $text_domain
156+
]
155157
);
158+
159+
return 0;
156160
}
157161

158162
/**

src/Command/Generate/MenuCommand.php

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
119119

120120
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
121121
if (!$this->confirmOperation()) {
122-
return;
122+
return 1;
123123
}
124124

125125
$this->generator->generate(
126-
$plugin,
127-
$class_name,
128-
$function_name,
129-
$menu_items,
130-
$child_themes
126+
[
127+
'plugin' => $plugin,
128+
'class_name' => $class_name,
129+
'function_name' => $function_name,
130+
'menu_items' => $menu_items,
131+
'child_theme' => $child_themes
132+
]
131133
);
134+
135+
return 0;
132136
}
133137

134138
/**
@@ -183,22 +187,22 @@ function ($menu) use ($stringConverter) {
183187
}
184188
);
185189

186-
if (!empty($menu)) {
187-
$description = $this->getIo()->ask(
188-
$this->trans('commands.generate.menu.questions.menu-items.description'),
189-
''
190-
);
191-
192-
array_push(
193-
$array_menu_items,
194-
[
195-
'name' => $stringConverter->camelCaseToUnderscore($name),
196-
'description' => $description,
197-
]
198-
);
190+
if (empty($name)) {
191+
break;
199192
}
200193

194+
$description = $this->getIo()->ask(
195+
$this->trans('commands.generate.menu.questions.menu-items.description'),
196+
''
197+
);
201198

199+
array_push(
200+
$array_menu_items,
201+
[
202+
'name' => $stringConverter->camelCaseToUnderscore($name),
203+
'description' => $description,
204+
]
205+
);
202206

203207
if (!$this->getIo()->confirm(
204208
$this->trans('commands.generate.menu.questions.menu-items.menu-add-another'),

src/Command/Generate/MetaBoxCommand.php

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
157157
{
158158
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
159159
if (!$this->confirmOperation()) {
160-
return;
160+
return 1;
161161
}
162162

163163
$plugin = $plugin = $this->validator->validatePluginName($input->getOption('plugin'));
@@ -173,18 +173,23 @@ protected function execute(InputInterface $input, OutputInterface $output)
173173
$auto_save = $input->getOption('auto-save');
174174

175175
$this->generator->generate(
176-
$plugin,
177-
$class_name,
178-
$metabox_id,
179-
$title,
180-
$callback_function,
181-
$screen,
182-
$page_location,
183-
$priority,
184-
$metabox_fields,
185-
$wp_nonce,
186-
$auto_save
176+
[
177+
"plugin" => $plugin,
178+
"class_name" => $class_name,
179+
"metabox_id" => $metabox_id,
180+
"title" => $title,
181+
"callback_function" => $callback_function,
182+
"screen" => $screen,
183+
"page_location" => $page_location,
184+
"priority" => $priority,
185+
"metabox_items" => $metabox_fields,
186+
"wp_nonce" => $wp_nonce,
187+
"auto_save" => $auto_save,
188+
189+
]
187190
);
191+
192+
return 0;
188193
}
189194

190195
/**
@@ -293,7 +298,7 @@ function ($function_name) {
293298
)
294299
) {
295300
// @see \WP\Console\Command\Shared\FieldsTypeTrait::fieldsQuestion
296-
$metabox_items = $this->fieldsQuestion($this->getIo(), 'metabox', 'metabox-items');
301+
$metabox_items = $this->fieldsQuestion('metabox', 'metabox-items');
297302
$input->setOption('metabox-items', $metabox_items);
298303
}
299304
}

src/Command/Generate/PluginCommand.php

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
161161
{
162162
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
163163
if (!$this->confirmOperation()) {
164-
return;
164+
return 1;
165165
}
166166

167167
$plugin = $this->validator->validatePluginName($input->getOption('plugin'));
@@ -186,19 +186,25 @@ protected function execute(InputInterface $input, OutputInterface $output)
186186
$className = $this->stringConverter->humanToCamelCase($plugin);
187187

188188
$this->generator->generate(
189-
$this->site,
190-
$plugin,
191-
$machineName,
192-
$pluginPath,
193-
$description,
194-
$author,
195-
$authorURL,
196-
$package,
197-
$className,
198-
$activate,
199-
$deactivate,
200-
$uninstall
189+
[
190+
'plugin' => $plugin,
191+
'plugin_uri' => '',
192+
'machine_name' => $machineName,
193+
'type' => 'module',
194+
'version' => $this->site->getBlogInfo('version'),
195+
'description' => $description,
196+
'author' => $author,
197+
'author_uri' => $authorURL,
198+
'package' => $package,
199+
'class_name_base' => $className,
200+
'activate' => $activate,
201+
'deactivate' => $deactivate,
202+
'uninstall' => $uninstall,
203+
'plugin_path' => $pluginPath
204+
]
201205
);
206+
207+
return 0;
202208
}
203209

204210
/**

src/Command/Generate/PostTypeCommand.php

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
204204
{
205205
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
206206
if (!$this->confirmOperation()) {
207-
return;
207+
return 1;
208208
}
209209

210210
$plugin = $plugin = $this->validator->validatePluginName($input->getOption('plugin'));
@@ -228,26 +228,30 @@ protected function execute(InputInterface $input, OutputInterface $output)
228228
$child_themes = $input->getOption('child-themes');
229229

230230
$this->generator->generate(
231-
$plugin,
232-
$class_name,
233-
$function_name,
234-
$post_type_key,
235-
$description,
236-
$singular_name,
237-
$plural_name,
238-
$post_type,
239-
$hierarchical,
240-
$exclude_from_search,
241-
$enable_export,
242-
$enable_archives,
243-
$labels,
244-
$supports,
245-
$visibility,
246-
$permalinks,
247-
$capabilities,
248-
$rest,
249-
$child_themes
231+
[
232+
"plugin" => $plugin,
233+
"class_name" => $class_name,
234+
"function_name" => $function_name,
235+
"post_type_key" => $post_type_key,
236+
"description" => $description,
237+
"name_singular" => $singular_name,
238+
"name_plural" => $plural_name,
239+
"taxonomy" => $post_type,
240+
"hierarchical" => $hierarchical,
241+
"exclude_from_search" => $exclude_from_search,
242+
"enable_export" => $enable_export,
243+
"enable_archives" => $enable_archives,
244+
"labels" => $labels,
245+
"supports" => $supports,
246+
"visibility" => $visibility,
247+
"permalinks" => $permalinks,
248+
"capabilities" => $capabilities,
249+
"rest" => $rest,
250+
"child_theme" => $child_themes,
251+
]
250252
);
253+
254+
return 0;
251255
}
252256

253257
/**

src/Command/Generate/QuickTagCommand.php

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -123,16 +123,20 @@ protected function execute(InputInterface $input, OutputInterface $output)
123123

124124
// @see use WP\Console\Command\Shared\ConfirmationTrait::confirmOperation
125125
if (!$this->confirmOperation()) {
126-
return;
126+
return 1;
127127
}
128128

129129
$this->generator->generate(
130-
$extensionType,
131-
$extension,
132-
$function_name,
133-
$quicktag_items,
130+
[
131+
"extension_type" => $extensionType,
132+
"extension" => $extension,
133+
"function_name" => $function_name,
134+
"quicktag_items" => $quicktag_items,
135+
],
134136
$this->site
135137
);
138+
139+
return 0;
136140
}
137141

138142
/**
@@ -177,6 +181,9 @@ function ($function_name) {
177181
$this->trans('commands.generate.quicktag.questions.quicktag-items.id'),
178182
'',
179183
function ($id) use ($stringConverter) {
184+
if (empty($id)) {
185+
throw new \Exception('You must entry a value');
186+
}
180187
return $stringConverter->humanToCamelCase($id);
181188
}
182189
);

0 commit comments

Comments
 (0)