Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
ShowModeCommand.php
Go to the documentation of this file.
1 <?php
8 
11 use Symfony\Component\Console\Command\Command;
12 use Symfony\Component\Console\Output\OutputInterface;
13 use Symfony\Component\Console\Input\InputInterface;
14 
18 class ShowModeCommand extends Command
19 {
25  private $objectManager;
26 
32  public function __construct(ObjectManagerInterface $objectManager)
33  {
34  $this->objectManager = $objectManager;
35  parent::__construct();
36  }
37 
41  protected function configure()
42  {
43  $description = 'Displays current application mode.';
44 
45  $this->setName('deploy:mode:show')->setDescription($description);
46  parent::configure();
47  }
48 
52  protected function execute(InputInterface $input, OutputInterface $output)
53  {
54  try {
56  $mode = $this->objectManager->create(
57  \Magento\Deploy\Model\Mode::class,
58  [
59  'input' => $input,
60  'output' => $output,
61  ]
62  );
63  $currentMode = $mode->getMode() ?: State::MODE_DEFAULT;
64  $output->writeln(
65  "Current application mode: $currentMode. (Note: Environment variables may override this value.)"
66  );
67  } catch (\Exception $e) {
68  $output->writeln('<error>' . $e->getMessage() . '</error>');
69  if ($output->getVerbosity() >= OutputInterface::VERBOSITY_VERBOSE) {
70  $output->writeln($e->getTraceAsString());
71  }
72  return;
73  }
74  }
75 }
__construct(ObjectManagerInterface $objectManager)
$objectManager
Definition: bootstrap.php:17
if($exist=($block->getProductCollection() && $block->getProductCollection() ->getSize())) $mode
Definition: grid.phtml:15