From a211aea267b288310d839c812235a009cd33aabc Mon Sep 17 00:00:00 2001 From: Sami Mokaddem Date: Tue, 17 Jan 2023 09:27:31 +0100 Subject: [PATCH] new: [command:metaTemaplate] Added meta-template shell to create and enabled template by UUID --- src/Command/MetaTemplateCommand.php | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/Command/MetaTemplateCommand.php diff --git a/src/Command/MetaTemplateCommand.php b/src/Command/MetaTemplateCommand.php new file mode 100644 index 0000000..e25538b --- /dev/null +++ b/src/Command/MetaTemplateCommand.php @@ -0,0 +1,48 @@ +setDescription('Load and enable the provided meta-template'); + $parser->addArgument('uuid', [ + 'help' => 'The UUID of the meta-template to load and enable', + 'required' => true + ]); + return $parser; + } + + public function execute(Arguments $args, ConsoleIo $io) + { + $this->io = $io; + $template_uuid = $args->getArgument('uuid'); + $metaTemplateTable = $this->modelClass; + $this->loadModel($metaTemplateTable); + $result = $this->MetaTemplates->createNewTemplate($template_uuid); + if (empty($result['success'])) { + $this->io->error(__('Could not create meta-template')); + $this->io->error(json_encode($result)); + die(1); + } + $template = $this->MetaTemplates->find()->where(['uuid' => $template_uuid])->first(); + if (!empty($template)) { + $template->enabled = true; + $success = $this->MetaTemplates->save($template); + if (!empty($success)) { + $this->io->success(__('Meta-template loaded and enabled')); + } + } + } +}