Author: david
Date: 2008-12-15 15:42:57 -0800 (Mon, 15 Dec 2008)
New Revision: 1687
Modified:
trunk/qubit/lib/task/migrate/MigrateTask.class.php
Log:
Data migrator: save output yaml file to same directory as input yaml file
instead of writing directly to data/fixtures.
Modified: trunk/qubit/lib/task/migrate/MigrateTask.class.php
===================================================================
--- trunk/qubit/lib/task/migrate/MigrateTask.class.php 2008-12-15 23:41:28 UTC
(rev 1686)
+++ trunk/qubit/lib/task/migrate/MigrateTask.class.php 2008-12-15 23:42:57 UTC
(rev 1687)
@@ -83,26 +83,23 @@
}
}
- // TODO: write new data.yml file
- $this->dumpDataFromArray($migrator->getData());
-
- // TODO: move sampleData.yml? (svn will be sad :( )
- // TODO: run propel:build-all-load?
+ // write new data.yml file
+ $this->dumpDataFromArray($arguments['datafile'], $migrator->getData());
}
- protected function dumpDataFromArray($data)
+ protected function dumpDataFromArray($originalFileName, $data)
{
- $yamlFileName = 'migrated_data_v104.yml';
- $dir = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures';
- $filename = $dir.DIRECTORY_SEPARATOR.$yamlFileName;
+ $migratedFileName = 'migrated_data_v104.yml';
+ $dir = dirname($originalFileName);
+ $migratedFileName = $dir.DIRECTORY_SEPARATOR.$migratedFileName;
$yamlDumper = new sfYamlDumper();
- $fileContents = sfYaml::dump($data, 3);
+ $yamlData = sfYaml::dump($data, 3);
- // Remove single quotes from <?php statements
- $fileContents = preg_replace("/'(\<\?php echo .+ \?\>)'/", '$1',
$fileContents);
+ // Remove single quotes from <?php statements to prevent errors on load
+ $yamlData = preg_replace("/'(\<\?php echo .+ \?\>)'/", '$1', $yamlData);
- file_put_contents($filename, $fileContents);
+ file_put_contents($migratedFileName, $yamlData);
}
protected function getDataVersion($data)
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Qubit Toolkit Commits" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.ca/group/qubit-commits?hl=en
-~----------~----~----~----~------~----~------~--~---