/** * Initialize DB configuration, db vendor and install dir * * @param string $magentoDir * @param string $localXmlFile * @param string $globalEtcFiles * @param string $moduleEtcFiles * @param string $tmpDir * @param string $cleanupAction */ public function __construct($magentoDir, $localXmlFile, $globalEtcFiles, $moduleEtcFiles, $tmpDir, $cleanupAction = self::CLEANUP_NONE, $developerMode = false) { if (!in_array($cleanupAction, array(self::CLEANUP_NONE, self::CLEANUP_UNINSTALL, self::CLEANUP_RESTORE_DB))) { throw new Exception("Cleanup action '{$cleanupAction}' is not supported."); } $this->_magentoDir = $magentoDir; $this->_localXmlFile = $localXmlFile; $this->_globalEtcFiles = $this->_exposeFiles($globalEtcFiles); $this->_moduleEtcFiles = $this->_exposeFiles($moduleEtcFiles); $this->_readLocalXml(); $this->_verifyDirectories($tmpDir); $sandboxUniqueId = md5(sha1_file($this->_localXmlFile) . '_' . $globalEtcFiles . '_' . $moduleEtcFiles); $this->_installDir = "{$tmpDir}/sandbox-{$this->_dbVendorName}-{$sandboxUniqueId}"; $this->_installEtcDir = $this->_installDir . '/etc'; $this->_db = $this->_instantiateDb(); $this->_cleanupAction = $cleanupAction; $this->_cleanup(); $this->_ensureDirExists($this->_installDir); $this->_developerMode = $developerMode; $this->_emulateEnvironment(); if ($this->_isInstalled()) { $this->initialize(); } else { $this->_db->verifyEmptyDatabase(); $this->_install(); } }