/** * Save backup from backup staging process * * @param object Enterprise_Staging_Model_Staging $staging * @param object Enterprise_Staging_Model_Staging_Log $log * * @return Enterprise_Staging_Model_Staging_Backup */ public function saveOnBackupRun(Enterprise_Staging_Model_Staging $staging, Enterprise_Staging_Model_Staging_Log $log) { if ($staging->getId()) { $name = $staging->getMasterWebsite()->getName(); $tablePrefix = Mage::getSingleton('enterprise_staging/staging_config')->getTablePrefix($staging) . Mage::getSingleton('enterprise_staging/staging_config')->getStagingBackupTablePrefix() . $log->getId() . "_"; $this->setStagingId($staging->getId())->setType('backup')->setEventCode($log->getAction())->setName($name)->setStatus(Enterprise_Staging_Model_Staging_Config::STATUS_COMPLETED)->setCreatedAt(Mage::registry($log->getAction() . "_event_start_time"))->setStagingTablePrefix($tablePrefix)->setMap($staging->getMapperInstance()->serialize())->setMageVersion(Mage::getVersion())->setMageModulesVersion(serialize(Mage::getSingleton('enterprise_staging/staging_config')->getCoreResourcesVersion())); $this->save(); } return $this; }
/** * Save system config resource model * * @param Enterprise_Staging_Model_Staging $staging * @param Mage_Core_Model_Website $stagingWebsite * @return Enterprise_Staging_Model_Staging_Adapter_Website */ protected function _saveSystemConfig($staging, Mage_Core_Model_Website $stagingWebsite, $entryPoint = null) { $masterWebsite = $staging->getMasterWebsite(); $unsecureBaseUrl = $stagingWebsite->getBaseUrl(); $secureBaseUrl = $stagingWebsite->getBaseSecureUrl(); if ($entryPoint && $entryPoint->isAutomatic()) { $unsecureBaseUrl = $entryPoint->getBaseUrl($masterWebsite); $secureBaseUrl = $entryPoint->getBaseUrl($masterWebsite, true); } $unsecureConf = Mage::getConfig()->getNode('default/web/unsecure'); $secureConf = Mage::getConfig()->getNode('default/web/secure'); if (!$masterWebsite->getIsStaging()) { $originalBaseUrl = (string) $masterWebsite->getConfig("web/unsecure/base_url"); } else { $originalBaseUrl = (string) Mage::getConfig()->getNode("default/web/unsecure/base_url"); } $this->_saveUrlsInSystemConfig($stagingWebsite, $originalBaseUrl, $unsecureBaseUrl, 'unsecure', $unsecureConf); if (strpos($secureBaseUrl, 'https') !== false) { if (!$masterWebsite->getIsStaging()) { $originalBaseUrl = (string) $masterWebsite->getConfig("web/secure/base_url"); } else { $originalBaseUrl = (string) Mage::getConfig()->getNode("default/web/secure/base_url"); } } $this->_saveUrlsInSystemConfig($stagingWebsite, $originalBaseUrl, $secureBaseUrl, 'secure', $secureConf); return $this; }
/** * Process staging itemsCallback * * @param string $callback * @param Enterprise_Staging_Model_Staging $staging * @param Enterprise_Staging_Model_Staging_Event $event * @param boolean $ignoreExtends * @return Enterprise_Staging_Model_Resource_Staging */ protected function _processStagingItemsCallback($callback, $staging, $event = null, $ignoreExtends = false) { $stagingItems = $staging->getMapperInstance()->getStagingItems(); foreach ($stagingItems as $stagingItem) { $adapter = $this->getItemAdapterInstanse($stagingItem); $adapter->{$callback}($staging, $event); if ($ignoreExtends) { continue; } if ($stagingItem->extends) { foreach ($stagingItem->extends->children() as $extendItem) { if (!Mage::getSingleton('enterprise_staging/staging_config')->isItemModuleActive($extendItem)) { continue; } $adapter = $this->getItemAdapterInstanse($extendItem); $adapter->{$callback}($staging, $event); } } } return $this; }
/** * Update specific attribute value (set new value back in given model) * * @param Enterprise_Staging_Model_Staging $staging * @param string $attribute * @param mixed $value * * @return Enterprise_Staging_Model_Mysql4_Staging_Website */ public function updateAttribute($staging, $attribute, $value) { if (!($stagingId = (int) $staging->getId())) { return $this; } $whereSql = "staging_id = {$stagingId}"; $this->_getWriteAdapter()->update($this->getMainTable(), array($attribute => $value), $whereSql); $staging->setData($attribute, $value); return $this; }