diff --git a/src/Scaffold/Console/CreateController.php b/src/Scaffold/Console/CreateController.php index 081d2ce99..dc0b85a4a 100644 --- a/src/Scaffold/Console/CreateController.php +++ b/src/Scaffold/Console/CreateController.php @@ -34,16 +34,34 @@ class CreateController extends GeneratorCommand * @var array */ protected $stubs = [ - 'controller/_list_toolbar.stub' => 'controllers/{{lower_name}}/_list_toolbar.htm', 'controller/config_form.stub' => 'controllers/{{lower_name}}/config_form.yaml', 'controller/config_list.stub' => 'controllers/{{lower_name}}/config_list.yaml', - 'controller/create.stub' => 'controllers/{{lower_name}}/create.htm', 'controller/index.stub' => 'controllers/{{lower_name}}/index.htm', - 'controller/preview.stub' => 'controllers/{{lower_name}}/preview.htm', - 'controller/update.stub' => 'controllers/{{lower_name}}/update.htm', 'controller/controller.stub' => 'controllers/{{studly_name}}.php', ]; + /** @inheritDoc */ + public function handle() + { + if ($this->option('with-translations')) { + $this->stubs = array_merge($this->stubs, [ + 'controller/_list_toolbar-with-translations.stub' => 'controllers/{{lower_name}}/_list_toolbar.htm', + 'controller/create-with-translations.stub' => 'controllers/{{lower_name}}/create.htm', + 'controller/preview-with-translations.stub' => 'controllers/{{lower_name}}/preview.htm', + 'controller/update-with-translations.stub' => 'controllers/{{lower_name}}/update.htm', + ]); + } else { + $this->stubs = array_merge($this->stubs, [ + 'controller/_list_toolbar.stub' => 'controllers/{{lower_name}}/_list_toolbar.htm', + 'controller/create.stub' => 'controllers/{{lower_name}}/create.htm', + 'controller/preview.stub' => 'controllers/{{lower_name}}/preview.htm', + 'controller/update.stub' => 'controllers/{{lower_name}}/update.htm', + ]); + } + + parent::handle(); // TODO: Change the autogenerated stub + } + /** * Prepare variables for stubs. * @@ -99,6 +117,7 @@ protected function getOptions() return [ ['force', null, InputOption::VALUE_NONE, 'Overwrite existing files with generated ones.'], ['model', null, InputOption::VALUE_OPTIONAL, 'Define which model name to use, otherwise the singular controller name is used.'], + ['with-translations', null, InputOption::VALUE_NONE, 'Generate view files with translation keys.'], ]; } } diff --git a/src/Scaffold/Console/controller/_list_toolbar-with-translations.stub b/src/Scaffold/Console/controller/_list_toolbar-with-translations.stub new file mode 100644 index 000000000..62c47434d --- /dev/null +++ b/src/Scaffold/Console/controller/_list_toolbar-with-translations.stub @@ -0,0 +1,21 @@ +
diff --git a/src/Scaffold/Console/controller/create-with-translations.stub b/src/Scaffold/Console/controller/create-with-translations.stub new file mode 100644 index 000000000..f66e9a0da --- /dev/null +++ b/src/Scaffold/Console/controller/create-with-translations.stub @@ -0,0 +1,48 @@ + += e(trans('backend::lang.form.return_to_list_name', ['name' => '{{lower_title_name}}'])) ?>
+ + diff --git a/src/Scaffold/Console/controller/preview-with-translations.stub b/src/Scaffold/Console/controller/preview-with-translations.stub new file mode 100644 index 000000000..5a7f3459a --- /dev/null +++ b/src/Scaffold/Console/controller/preview-with-translations.stub @@ -0,0 +1,19 @@ + += e(trans('backend::lang.form.return_to_list_name', ['name' => '{{lower_title_name}}'])) ?>
+ + diff --git a/src/Scaffold/Console/controller/update-with-translations.stub b/src/Scaffold/Console/controller/update-with-translations.stub new file mode 100644 index 000000000..fa488f73f --- /dev/null +++ b/src/Scaffold/Console/controller/update-with-translations.stub @@ -0,0 +1,56 @@ + += e(trans('backend::lang.form.return_to_list_name', ['name' => '{{lower_title_name}}'])) ?>
+ +