Menu.php 878 B

12345678910111213141516171819202122232425262728293031323334
  1. <?php
  2. declare ( strict_types = 1 );
  3. namespace app\command;
  4. use app\service\admin\install\InstallSystemService;
  5. use app\service\core\menu\CoreMenuService;
  6. use think\console\Command;
  7. use think\console\Input;
  8. use think\console\input\Option;
  9. use think\console\Output;
  10. class Menu extends Command
  11. {
  12. protected function configure()
  13. {
  14. // 指令配置
  15. $this->setName('menu')
  16. ->addOption('addon', 'a', Option::VALUE_OPTIONAL)
  17. ->setDescription('the menu command');
  18. }
  19. protected function execute(Input $input, Output $output)
  20. {
  21. $addon = $input->getOption('addon');
  22. if ($addon) {
  23. ( new CoreMenuService() )->refreshAddonMenu($addon);
  24. } else {
  25. ( new InstallSystemService() )->installMenu();
  26. }
  27. // 指令输出
  28. $output->writeln('menu refresh success');
  29. }
  30. }