Skip to content

Instantly share code, notes, and snippets.

@kriswallsmith
Created October 23, 2009 15:40
Show Gist options
  • Save kriswallsmith/216986 to your computer and use it in GitHub Desktop.
Save kriswallsmith/216986 to your computer and use it in GitHub Desktop.
<?php
// copy schema files to tmp directory and apply default behaviors there
$tmpDir = sys_get_temp_dir().'sf_propel_plugin/phingproj_'.time().'_'.rand(11111, 99999);
$this->getFilesystem()->mkdirs($tmpDir);
$this->getFilesystem()->copy(sfConfig::get('sf_config_dir').'/propel.ini', $tmpDir.'/propel.ini');
$buildProperties = new Properties();
$buildProperties->load(new PhingFile($tmpDir.'/propel.ini'));
$finder = sfFinder::type('file')->name('*schema.xml')->follow_link();
foreach ($finder->in(sfConfig::get('sf_config_dir')) as $source)
{
$target = $tmpDir.'/'.basename($source);
$database = new SimpleXMLElement($source, null, true);
$behaviors = $this->getBehaviors($database);
foreach ($database->table as $table)
{
$this->addDefaultBehaviors($table, $behaviors, $buildProperties);
}
$this->logSection('file+', $target);
file_put_contents($target, $database->asXml());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment