AppPluginUpdateCommand.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. <?php
  2. namespace Webman\Console\Commands;
  3. use Symfony\Component\Console\Command\Command;
  4. use Symfony\Component\Console\Input\InputArgument;
  5. use Symfony\Component\Console\Input\InputInterface;
  6. use Symfony\Component\Console\Output\OutputInterface;
  7. use Symfony\Component\Console\Input\InputOption;
  8. use Webman\Console\Util;
  9. class AppPluginUpdateCommand extends Command
  10. {
  11. protected static $defaultName = 'app-plugin:update';
  12. protected static $defaultDescription = 'App Plugin Update';
  13. /**
  14. * @return void
  15. */
  16. protected function configure()
  17. {
  18. $this->addArgument('name', InputArgument::REQUIRED, 'App plugin name');
  19. }
  20. /**
  21. * @param InputInterface $input
  22. * @param OutputInterface $output
  23. * @return int
  24. */
  25. protected function execute(InputInterface $input, OutputInterface $output): int
  26. {
  27. $name = $input->getArgument('name');
  28. $output->writeln("Update App Plugin $name");
  29. $class = "\\plugin\\$name\\api\\Install";
  30. if (!method_exists($class, 'update')) {
  31. throw new \RuntimeException("Method $class::update not exists");
  32. }
  33. call_user_func([$class, 'update'], config("plugin.$name.app.version"), config("plugin.$name.app.version"));
  34. return self::SUCCESS;
  35. }
  36. }