Skouter mortgage estimates. Web application with view written in PHP and Vue, but controller and models in Go.
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

NewBlueprintCommand.php 2.4 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Grav\Plugin\Console;
  3. use Symfony\Component\Console\Input\InputOption;
  4. use Symfony\Component\Console\Question\ChoiceQuestion;
  5. use Symfony\Component\Console\Question\Question;
  6. require_once(__DIR__ . '/../classes/DevToolsCommand.php');
  7. /**
  8. * Class NewThemeCommand
  9. * @package Grav\Console\Cli\DevTools
  10. */
  11. class NewBlueprintCommand extends DevToolsCommand
  12. {
  13. /**
  14. * @return void
  15. */
  16. protected function configure(): void
  17. {
  18. $this
  19. ->setName('new-blueprint')
  20. ->setAliases(['newblueprint','blueprint'])
  21. ->addOption(
  22. 'bpname',
  23. null,
  24. InputOption::VALUE_OPTIONAL,
  25. 'The name of your new Grav theme'
  26. )
  27. ->addOption(
  28. 'name',
  29. null,
  30. InputOption::VALUE_OPTIONAL,
  31. 'The name of your new Grav theme'
  32. )
  33. ->addOption(
  34. 'template',
  35. null,
  36. InputOption::VALUE_OPTIONAL,
  37. 'The name/username of the developer'
  38. )
  39. ->setDescription('Create a blueprint that extend the default.yaml blueprint files')
  40. ->setHelp('The <info>new-blueprint</info> command creates a new blueprint file.');
  41. }
  42. /**
  43. * @return int
  44. */
  45. protected function serve(): int
  46. {
  47. $this->init();
  48. $input = $this->getInput();
  49. $io = $this->getIO();
  50. $this->component['type'] = 'blueprint';
  51. $this->component['template'] = 'modular';
  52. $this->component['version'] = '0.1.0';
  53. $this->component['themename'] = 'bonjour';
  54. $this->options = [
  55. 'name' => $input->getOption('name'),
  56. 'bpname' => $input->getOption('bpname'),
  57. 'template' => $input->getOption('template'),
  58. ];
  59. $this->validateOptions();
  60. $this->component = array_replace($this->component, $this->options);
  61. if (!$this->options['template']) {
  62. $question = new ChoiceQuestion('Please choose a template type', ['newtab', 'append']);
  63. $this->component['template'] = $io->askQuestion($question);
  64. }
  65. if (!$this->options['bpname']) {
  66. $question = new Question('Enter <yellow>Blueprint Name</yellow>');
  67. $this->component['bpname'] = $io->askQuestion($question);
  68. }
  69. $this->createComponent();
  70. return 0;
  71. }
  72. }