ConfigImportCommand.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Deploy\Console\Command\App;
  7. use Magento\Framework\Exception\RuntimeException;
  8. use Symfony\Component\Console\Command\Command;
  9. use Symfony\Component\Console\Input\InputInterface;
  10. use Symfony\Component\Console\Output\OutputInterface;
  11. use Magento\Framework\Console\Cli;
  12. use Magento\Deploy\Console\Command\App\ConfigImport\Processor;
  13. /**
  14. * Runs the process of importing configuration data from shared source to appropriate application sources
  15. *
  16. * We have configuration files that are shared between environments, but some of the configurations are read only
  17. * from DB (e.g., themes, scopes and etc). This command is used to import such configurations from the file to
  18. * appropriate application sources
  19. */
  20. class ConfigImportCommand extends Command
  21. {
  22. /**
  23. * Command name.
  24. */
  25. const COMMAND_NAME = 'app:config:import';
  26. /**
  27. * Configuration importer.
  28. *
  29. * @var Processor
  30. */
  31. private $processor;
  32. /**
  33. * @param Processor $processor the configuration importer
  34. */
  35. public function __construct(Processor $processor)
  36. {
  37. $this->processor = $processor;
  38. parent::__construct();
  39. }
  40. /**
  41. * @inheritdoc
  42. */
  43. protected function configure()
  44. {
  45. $this->setName(self::COMMAND_NAME)
  46. ->setDescription('Import data from shared configuration files to appropriate data storage');
  47. parent::configure();
  48. }
  49. /**
  50. * Imports data from deployment configuration files to the DB. {@inheritdoc}
  51. */
  52. protected function execute(InputInterface $input, OutputInterface $output)
  53. {
  54. try {
  55. $this->processor->execute($input, $output);
  56. } catch (RuntimeException $e) {
  57. $output->writeln('<error>' . $e->getMessage() . '</error>');
  58. return Cli::RETURN_FAILURE;
  59. }
  60. return Cli::RETURN_SUCCESS;
  61. }
  62. }