X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FYaml%2FUpdateKeyCommand.php;fp=vendor%2Fdrupal%2Fconsole-core%2Fsrc%2FCommand%2FYaml%2FUpdateKeyCommand.php;h=0000000000000000000000000000000000000000;hp=7f6410a65aedf5bdb97c37622be02d2c4879c2e1;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hpb=aea91e65e895364e460983b890e295aa5d5540a5 diff --git a/vendor/drupal/console-core/src/Command/Yaml/UpdateKeyCommand.php b/vendor/drupal/console-core/src/Command/Yaml/UpdateKeyCommand.php deleted file mode 100644 index 7f6410a65..000000000 --- a/vendor/drupal/console-core/src/Command/Yaml/UpdateKeyCommand.php +++ /dev/null @@ -1,116 +0,0 @@ -nestedArray = $nestedArray; - parent::__construct(); - } - - protected function configure() - { - $this - ->setName('yaml:update:key') - ->setDescription($this->trans('commands.yaml.update.key.description')) - ->addArgument( - 'yaml-file', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-file') - ) - ->addArgument( - 'yaml-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-key') - ) - ->addArgument( - 'yaml-new-key', - InputArgument::REQUIRED, - $this->trans('commands.yaml.update.value.arguments.yaml-new-key') - ); - } - - protected function execute(InputInterface $input, OutputInterface $output) - { - $io = new DrupalStyle($input, $output); - - $yaml = new Parser(); - $dumper = new Dumper(); - - $yaml_file = $input->getArgument('yaml-file'); - $yaml_key = $input->getArgument('yaml-key'); - $yaml_new_key = $input->getArgument('yaml-new-key'); - - try { - $yaml_parsed = $yaml->parse(file_get_contents($yaml_file)); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-parsing').': '.$e->getMessage()); - - return; - } - - if (empty($yaml_parsed)) { - $io->info( - sprintf( - $this->trans('commands.yaml.merge.messages.wrong-parse'), - $yaml_file - ) - ); - } - - $parents = explode(".", $yaml_key); - $this->nestedArray->replaceKey($yaml_parsed, $parents, $yaml_new_key); - - try { - $yaml = $dumper->dump($yaml_parsed, 10); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-generating').': '.$e->getMessage()); - - return; - } - - try { - file_put_contents($yaml_file, $yaml); - } catch (\Exception $e) { - $io->error($this->trans('commands.yaml.merge.messages.error-writing').': '.$e->getMessage()); - - return; - } - - $io->info( - sprintf( - $this->trans('commands.yaml.update.value.messages.updated'), - $yaml_file - ) - ); - } -}