protected function execute(InputInterface $input, OutputInterface $output)
{
$this->detectMagento($output);
if (!$this->initMagento()) {
return;
}
// setting the options - hypernode demands it
$this->_options = $input->getOptions();
// finding the effective url e.g. store.nl -> https://www.store.nl
if ($this->_options['current-url'] && $this->_options['compare-url']) {
$this->_options['current-url'] = $this->getEffectiveUrl($this->_options['current-url']);
$this->_options['compare-url'] = $this->getEffectiveUrl($this->_options['compare-url']);
}
// get sitemaps to process
if (!$this->_options['sitemap'] && !$this->_options['silent']) {
$this->_sitemaps = $this->askSitemapsToProcess($input, $output);
} else {
if (!$this->_options['sitemap'] && $this->_options['silent']) {
$this->_sitemaps = $this->retrieveSitemaps();
} else {
$sitemapFromInput = $this->getSitemapFromInput($this->_options);
if (!$sitemapFromInput) {
$output->writeln('<error>Could not fetch specified sitemap: ' . $this->_options['sitemap'] . '</error>');
} else {
$this->_sitemaps = $sitemapFromInput;
}
}
}
// prepare the requests
if ($this->_sitemaps) {
$this->_batches = $this->prepareRequests($input, $output);
}
// execute the requests
if ($this->_batches) {
$this->_results = $this->executeBatches($input, $output);
}
// serve the results
if ($this->_results) {
if ($this->_options['silent'] && !$this->_options['format']) {
$output->write(json_encode($this->_results) . PHP_EOL);
// hypernode internal
} else {
$tableHelper = $this->getHelper('table');
if ($this->_options['format']) {
// user specified format
$tableData = $this->generateTablesDataForFormat($this->_results);
} else {
$tableData = $this->generateTablesData($this->_results);
}
foreach ($tableData as $data) {
if (!$this->_options['silent']) {
$this->writeSection($output, "Performance status report - [Byte Hypernode]");
}
$tableHelper->setHeaders($data['headers']);
if ($this->_options['format']) {
$tableHelper->renderByFormat($output, $data['requests'], $this->_options['format']);
} else {
$tableHelper->renderByFormat($output, $data['requests']);
}
}
}
}
}