diff --git a/src/Scaffold/Console/CreateSettings.php b/src/Scaffold/Console/CreateSettings.php new file mode 100644 index 000000000..a9bf99b83 --- /dev/null +++ b/src/Scaffold/Console/CreateSettings.php @@ -0,0 +1,73 @@ + 'models/{{studly_name}}.php', + 'settings/fields.stub' => 'models/{{lower_name}}/fields.yaml' + ]; + + /** + * Prepare variables for stubs. + * + * return @array + */ + protected function prepareVars() + { + $pluginCode = $this->argument('plugin'); + + $parts = explode('.', $pluginCode); + $plugin = array_pop($parts); + $author = array_pop($parts); + $settings = $this->argument('settings') ?? 'Settings'; + + return [ + 'name' => $settings, + 'author' => $author, + 'plugin' => $plugin + ]; + } + + /** + * Get the console command arguments. + * + * @return array + */ + protected function getArguments() + { + return [ + ['plugin', InputArgument::REQUIRED, 'The name of the plugin. Eg: Winter.Blog'], + ['settings', InputArgument::OPTIONAL, 'The name of the settings model. Eg: Settings'], + ]; + } +} diff --git a/src/Scaffold/Console/settings/fields.stub b/src/Scaffold/Console/settings/fields.stub new file mode 100644 index 000000000..7a890bd71 --- /dev/null +++ b/src/Scaffold/Console/settings/fields.stub @@ -0,0 +1,7 @@ +# =================================== +# Form Field Definitions +# =================================== + +fields: + settings_option: + label: This is a sample settings field used by {{author}}.{{plugin}} diff --git a/src/Scaffold/Console/settings/model.stub b/src/Scaffold/Console/settings/model.stub new file mode 100644 index 000000000..740e775a9 --- /dev/null +++ b/src/Scaffold/Console/settings/model.stub @@ -0,0 +1,31 @@ + CreateTheme::class, 'command.create.plugin' => CreatePlugin::class, 'command.create.model' => CreateModel::class, + 'command.create.settings' => CreateSettings::class, 'command.create.controller' => CreateController::class, 'command.create.component' => CreateComponent::class, 'command.create.formwidget' => CreateFormWidget::class, @@ -42,6 +44,7 @@ public function register() 'command.create.theme', 'command.create.plugin', 'command.create.model', + 'command.create.settings', 'command.create.controller', 'command.create.component', 'command.create.formwidget', @@ -63,6 +66,7 @@ public function provides() 'command.create.theme', 'command.create.plugin', 'command.create.model', + 'command.create.settings', 'command.create.controller', 'command.create.component', 'command.create.formwidget',