Magento 2 Documentation  2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
DbStatusCommand.php
Go to the documentation of this file.
1 <?php
7 
16 use Symfony\Component\Console\Input\InputInterface;
17 use Symfony\Component\Console\Output\OutputInterface;
18 
23 {
28 
34  private $objectManagerProvider;
35 
41  private $deploymentConfig;
42 
46  private $upToDateValidators = [];
47 
54  public function __construct(ObjectManagerProvider $objectManagerProvider, DeploymentConfig $deploymentConfig)
55  {
56  $this->objectManagerProvider = $objectManagerProvider;
57  $this->deploymentConfig = $deploymentConfig;
62  $this->upToDateValidators = [
63  $this->objectManagerProvider->get()->get(UpToDateDeclarativeSchema::class),
64  $this->objectManagerProvider->get()->get(UpToDateSchema::class),
65  $this->objectManagerProvider->get()->get(UpToDateData::class),
66  $this->objectManagerProvider->get()->get(OldDbValidator::class),
67  ];
68  parent::__construct();
69  }
70 
74  protected function configure()
75  {
76  $this->setName('setup:db:status')
77  ->setDescription('Checks if DB schema or data requires upgrade');
78  parent::configure();
79  }
80 
84  protected function execute(InputInterface $input, OutputInterface $output)
85  {
86  if (!$this->deploymentConfig->isAvailable()) {
87  $output->writeln(
88  "<info>No information is available: the Magento application is not installed.</info>"
89  );
90  return Cli::RETURN_FAILURE;
91  }
92 
93  $outDated = false;
94 
95  foreach ($this->upToDateValidators as $validator) {
96  if (!$validator->isUpToDate()) {
97  $output->writeln(sprintf('<info>%s</info>', $validator->getNotUpToDateMessage()));
98  $outDated = true;
99  }
100  }
101 
102  if ($outDated) {
103  $output->writeln('<info>Run \'setup:upgrade\' to update your DB schema and data.</info>');
105  }
106 
107  $output->writeln(
108  '<info>All modules are up to date.</info>'
109  );
110  return Cli::RETURN_SUCCESS;
111  }
112 }
execute(InputInterface $input, OutputInterface $output)
__construct(ObjectManagerProvider $objectManagerProvider, DeploymentConfig $deploymentConfig)
$deploymentConfig