IndexerShowModeCommand.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. /**
  3. * Copyright © Magento, Inc. All rights reserved.
  4. * See COPYING.txt for license details.
  5. */
  6. namespace Magento\Indexer\Console\Command;
  7. use Symfony\Component\Console\Input\InputInterface;
  8. use Symfony\Component\Console\Output\OutputInterface;
  9. /**
  10. * Command for displaying current index mode for indexers.
  11. */
  12. class IndexerShowModeCommand extends AbstractIndexerManageCommand
  13. {
  14. /**
  15. * {@inheritdoc}
  16. */
  17. protected function configure()
  18. {
  19. $this->setName('indexer:show-mode')
  20. ->setDescription('Shows Index Mode')
  21. ->setDefinition($this->getInputList());
  22. parent::configure();
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. protected function execute(InputInterface $input, OutputInterface $output)
  28. {
  29. $indexers = $this->getIndexers($input);
  30. foreach ($indexers as $indexer) {
  31. $status = $indexer->isScheduled() ? 'Update by Schedule' : 'Update on Save';
  32. $output->writeln(sprintf('%-50s ', $indexer->getTitle() . ':') . $status);
  33. }
  34. }
  35. }