CommandList.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Deploy\Console;
  7. use Magento\Framework\ObjectManagerInterface;
  8. /**
  9. * Provides list of commands to be available for uninstalled application
  10. */
  11. class CommandList implements \Magento\Framework\Console\CommandListInterface
  12. {
  13. /**
  14. * Object Manager
  15. *
  16. * @var ObjectManagerInterface
  17. */
  18. private $objectManager;
  19. /**
  20. * @param ObjectManagerInterface $objectManager Object Manager
  21. */
  22. public function __construct(ObjectManagerInterface $objectManager)
  23. {
  24. $this->objectManager = $objectManager;
  25. }
  26. /**
  27. * Gets list of command classes
  28. *
  29. * @return string[]
  30. */
  31. private function getCommandsClasses()
  32. {
  33. return [
  34. \Magento\Deploy\Console\Command\App\ConfigImportCommand::class,
  35. ];
  36. }
  37. /**
  38. * @inheritdoc
  39. */
  40. public function getCommands()
  41. {
  42. $commands = [];
  43. foreach ($this->getCommandsClasses() as $class) {
  44. if (class_exists($class)) {
  45. $commands[] = $this->objectManager->get($class);
  46. } else {
  47. throw new \Exception('Class ' . $class . ' does not exist');
  48. }
  49. }
  50. return $commands;
  51. }
  52. }