From Enterprise_Staging_Model_Entry
/**
* Create entry point if possible
*
* @return Enterprise_Staging_Model_Entry
*/
public function save()
{
$this->_ensureWebsite();
if ($this->canEntryPointBeCreated()) {
$sample = file_get_contents(BP . DS . 'index.php.sample');
$outputFile = $this->getFilename();
if (!is_dir(dirname($outputFile))) {
mkdir(dirname($outputFile));
}
$result = str_replace(
array('include $', 'app/Mage.php'),
array('include \'../../\' . $', '../../app/Mage.php'),
$sample
);
$result = preg_replace('/Mage::run\(.*?\)/us', "Mage::run('{$this->_website->getCode()}', 'website')", $result);
file_put_contents($outputFile, $result);
$sample = file_get_contents(BP . DS . '.htaccess.sample');
$search = <<<SEARCH
############################################
## workaround for HTTP authorization
## in CGI environment
SEARCH;
$replace = <<<REPLACE
############################################
## add 'no_cache' GET parameter for staging sites
RewriteCond %{QUERY_STRING} !(^|[?&])no_cache([&=]|$)
RewriteRule (.*) $1?no_cache [QSA]
############################################
## workaround for HTTP authorization
## in CGI environment
REPLACE;
$sample = str_replace($search, $replace, $sample);
$outputFile = $this->getBaseFolder() . DS . $this->_website->getCode() . DS . '.htaccess';
file_put_contents($outputFile, $sample);
}
return $this;
}
Make sure index.php.sample
and .htaccess.sample
exist. They are copied when creating a new staging environment.