/** * @param \Symfony\Component\Console\Input\InputInterface $input * @param \Symfony\Component\Console\Output\OutputInterface $output * @return int|null|void */ protected function execute(InputInterface $input, OutputInterface $output) { $time = microtime(true); $ignoreDataUpdate = $input->getOption('ignore-data'); $headers = array('Setup', 'Module', 'DB', 'Data', 'Status'); if ($ignoreDataUpdate) { unset($headers[array_search('Data', $headers)]); } $errorCounter = 0; $table = array(); foreach ($this->moduleList->getAll() as $moduleName => $moduleInfo) { $moduleVersion = $moduleInfo['setup_version']; $dbVersion = $this->resource->getDbVersion($moduleName); if (!$ignoreDataUpdate) { $dataVersion = $this->resource->getDataVersion($moduleName); } $ok = $dbVersion == $moduleVersion; if ($ok && !$ignoreDataUpdate) { $ok = $dataVersion == $moduleVersion; } if (!$ok) { $errorCounter++; } $row = array('Module' => $moduleName, 'DB' => $dbVersion, 'Data' => $dataVersion); if (!$ignoreDataUpdate) { $row['Data-Version'] = $dataVersion; } $row['Status'] = $ok ? 'OK' : 'Error'; $table[] = $row; } //if there is no output format //highlight the status //and show error'd rows at bottom if (!$input->getOption('format')) { usort($table, function ($a, $b) { return $a['Status'] !== 'OK'; }); array_walk($table, function (&$row) { $status = $row['Status']; $availableStatus = array('OK' => 'info', 'Error' => 'error'); $statusString = sprintf('<%s>%s</%s>', $availableStatus[$status], $status, $availableStatus[$status]); $row['Status'] = $statusString; }); } if ($input->getOption('log-junit')) { $this->logJUnit($table, $input->getOption('log-junit'), microtime($time) - $time); } else { $this->getHelper('table')->setHeaders($headers)->renderByFormat($output, $table, $input->getOption('format')); //if no output format specified - output summary line if (!$input->getOption('format')) { if ($errorCounter > 0) { $this->writeSection($output, sprintf('%s error%s %s found!', $errorCounter, $errorCounter === 1 ? '' : 's', $errorCounter === 1 ? 'was' : 'were'), 'error'); } else { $this->writeSection($output, 'No setup problems were found.', 'info'); } } } }
/** * Get Magefan Modules Info * * @return $this */ protected function getMagefanModules() { $modules = array(); foreach ($this->_moduleList->getAll() as $moduleName => $module) { if (strpos($moduleName, 'Magefan_') !== false && $this->_moduleManager->isEnabled($moduleName)) { $modules[$moduleName] = $module; } } return $modules; }
protected function prepareModuleList($vendor) { $this->moduleList = []; foreach ($this->moduleListObject->getAll() as $moduleName => $info) { // First index is (probably always) vendor $moduleNameData = explode('_', $moduleName); if (!is_null($vendor) && strtolower($moduleNameData[0]) !== strtolower($vendor)) { continue; } $this->moduleList[] = [$info['name'], $info['setup_version']]; } }
protected function addVendors() { $vendors = []; $moduleList = $this->moduleList->getAll(); foreach ($moduleList as $moduleName => $info) { // First index is (probably always) vendor $moduleNameData = explode('_', $moduleName); if (isset($moduleNameData[0])) { $vendors[] = $moduleNameData[0]; } } $this->infos['Vendors'] = implode(', ', array_unique($vendors)); }
/** * @return array */ protected function getMagentoModuleList() { return $this->moduleList->getAll(); }