GravCommand.php 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @package Grav\Console
  4. *
  5. * @copyright Copyright (c) 2015 - 2023 Trilby Media, LLC. All rights reserved.
  6. * @license MIT License; see LICENSE file for details.
  7. */
  8. namespace Grav\Console;
  9. use Symfony\Component\Console\Command\Command;
  10. use Symfony\Component\Console\Input\InputInterface;
  11. use Symfony\Component\Console\Output\OutputInterface;
  12. /**
  13. * Class ConsoleCommand
  14. * @package Grav\Console
  15. */
  16. class GravCommand extends Command
  17. {
  18. use ConsoleTrait;
  19. /**
  20. * @param InputInterface $input
  21. * @param OutputInterface $output
  22. * @return int
  23. */
  24. protected function execute(InputInterface $input, OutputInterface $output)
  25. {
  26. $this->setupConsole($input, $output);
  27. // Old versions of Grav called this command after grav upgrade.
  28. // We need make this command to work with older ConsoleTrait:
  29. if (method_exists($this, 'initializeGrav')) {
  30. $this->initializeGrav();
  31. }
  32. return $this->serve();
  33. }
  34. /**
  35. * Override with your implementation.
  36. *
  37. * @return int
  38. */
  39. protected function serve()
  40. {
  41. // Return error.
  42. return 1;
  43. }
  44. }