diff options
author | Robin Appelman <robin@icewind.nl> | 2020-01-27 15:50:20 +0300 |
---|---|---|
committer | Robin Appelman <robin@icewind.nl> | 2020-01-27 15:50:20 +0300 |
commit | f1b67feb1e40b6a888fedbb0213e0c7f93734b24 (patch) | |
tree | e13cfd5ed3822c4bd044e52ea96251aa5b4b12fc /lib | |
parent | 740bd62a2500dda1a69a849532025607ef8dbf2e (diff) |
allow adding or removing multiple fonts at once
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Command/Fonts.php | 45 |
1 files changed, 26 insertions, 19 deletions
diff --git a/lib/Command/Fonts.php b/lib/Command/Fonts.php index cdf9c7a..37cc6e5 100644 --- a/lib/Command/Fonts.php +++ b/lib/Command/Fonts.php @@ -41,33 +41,40 @@ class Fonts extends Base { protected function configure() { $this ->setName('documentserver:fonts') - ->addOption('add', 'a', InputOption::VALUE_REQUIRED, 'Add a font from local file') - ->addOption('remove', 'r', InputOption::VALUE_REQUIRED, 'Remove a font by name') + ->addOption('add', 'a', InputOption::VALUE_IS_ARRAY + InputOption::VALUE_REQUIRED, 'Add a font from local file') + ->addOption('remove', 'r', InputOption::VALUE_IS_ARRAY + InputOption::VALUE_REQUIRED, 'Remove a font by name') + ->addOption('rebuild', null, InputOption::VALUE_NONE, 'Rebuild the onlyoffice fonts from added fonts') ->setDescription('Manage custom fonts'); parent::configure(); } protected function execute(InputInterface $input, OutputInterface $output) { - if ($add = $input->getOption('add')) { - try { - $this->fontManager->addFont($add); - $this->fontManager->rebuildFonts(); - } catch (\Exception $e) { - $error = $e->getMessage(); - $output->writeln("<error>$error</error>"); + $add = $input->getOption('add'); + $remove = $input->getOption('remove'); + $rebuild = $input->getOption('rebuild'); + try { + foreach ($add as $font) { + $this->fontManager->addFont($font); } - } else if ($remove = $input->getOption('remove')) { - $this->fontManager->removeFont($remove); - $this->fontManager->rebuildFonts(); - } else { - $fonts = $this->fontManager->listFonts(); - if ($fonts) { - foreach ($fonts as $font) { - $output->writeln($font); - } + foreach ($remove as $font) { + $this->fontManager->removeFont($font); + } + if ($add || $remove || $rebuild) { + $output->writeln("<info>rebuilding</info>"); + $this->fontManager->rebuildFonts(); } else { - $output->writeln("<info>No fonts added</info>"); + $fonts = $this->fontManager->listFonts(); + if ($fonts) { + foreach ($fonts as $font) { + $output->writeln($font); + } + } else { + $output->writeln("<info>No fonts added</info>"); + } } + } catch (\Exception $e) { + $error = $e->getMessage(); + $output->writeln("<error>$error</error>"); } } } |