protected function _search($searchFolder)
{
if (OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity()) {
$this->output->writeln('<debug>Search for Magento in folder <info>' . $searchFolder . '</info></debug>');
}
if (!is_dir($searchFolder . '/app')) {
return false;
}
$finder = Finder::create();
$finder->ignoreUnreadableDirs(true)->depth(0)->followLinks()->name('Mage.php')->name('bootstrap.php')->name('autoload.php')->in($searchFolder . '/app');
if ($finder->count() > 0) {
$files = iterator_to_array($finder, false);
/* @var $file \SplFileInfo */
$hasMageFile = false;
foreach ($files as $file) {
if ($file->getFilename() == 'Mage.php') {
$hasMageFile = true;
}
}
$this->_magentoRootFolder = $searchFolder;
// Magento 2 does not have a god class and thus if this file is not there it is version 2
if ($hasMageFile == false) {
$this->_magentoMajorVersion = Application::MAGENTO_MAJOR_VERSION_2;
return true;
// the rest of this does not matter since we are simply exiting with a notice
}
if (is_callable(array('\\Mage', 'getEdition'))) {
$this->_magentoEnterprise = \Mage::getEdition() == 'Enterprise';
} else {
$this->_magentoEnterprise = is_dir($this->_magentoRootFolder . '/app/code/core/Enterprise');
}
if (OutputInterface::VERBOSITY_DEBUG <= $this->output->getVerbosity()) {
$this->output->writeln('<debug>Found Magento in folder <info>' . $this->_magentoRootFolder . '</info></debug>');
}
return true;
}
return false;
}