| 220 | | * loads yml data from fixtures directory and inserts into database |
|---|
| | 223 | * Dumps yml database data to fixtures directory. |
|---|
| | 224 | * |
|---|
| | 225 | * @example symfony dump-data frontend data.yml |
|---|
| | 226 | * @example symfony dump-data frontend data.yml dev |
|---|
| | 227 | * |
|---|
| | 228 | * @param object $task |
|---|
| | 229 | * @param array $args |
|---|
| | 230 | */ |
|---|
| | 231 | function run_propel_dump_data($task, $args) |
|---|
| | 232 | { |
|---|
| | 233 | if (!count($args)) |
|---|
| | 234 | { |
|---|
| | 235 | throw new Exception('You must provide the app.'); |
|---|
| | 236 | } |
|---|
| | 237 | |
|---|
| | 238 | $app = $args[0]; |
|---|
| | 239 | |
|---|
| | 240 | if (!is_dir(sfConfig::get('sf_app_dir').DIRECTORY_SEPARATOR.$app)) |
|---|
| | 241 | { |
|---|
| | 242 | throw new Exception('The app "'.$app.'" does not exist.'); |
|---|
| | 243 | } |
|---|
| | 244 | |
|---|
| | 245 | if (!isset($args[1])) |
|---|
| | 246 | { |
|---|
| | 247 | throw new Exception('You must provide a filename.'); |
|---|
| | 248 | } |
|---|
| | 249 | |
|---|
| | 250 | $filename = $args[1]; |
|---|
| | 251 | |
|---|
| | 252 | $env = empty($args[2]) ? 'dev' : $args[2]; |
|---|
| | 253 | |
|---|
| | 254 | // define constants |
|---|
| | 255 | define('SF_ROOT_DIR', sfConfig::get('sf_root_dir')); |
|---|
| | 256 | define('SF_APP', $app); |
|---|
| | 257 | define('SF_ENVIRONMENT', $env); |
|---|
| | 258 | define('SF_DEBUG', true); |
|---|
| | 259 | |
|---|
| | 260 | // get configuration |
|---|
| | 261 | require_once SF_ROOT_DIR.DIRECTORY_SEPARATOR.'apps'.DIRECTORY_SEPARATOR.SF_APP.DIRECTORY_SEPARATOR.'config'.DIRECTORY_SEPARATOR.'config.php'; |
|---|
| | 262 | |
|---|
| | 263 | $databaseManager = new sfDatabaseManager(); |
|---|
| | 264 | $databaseManager->initialize(); |
|---|
| | 265 | |
|---|
| | 266 | if (!sfToolkit::isPathAbsolute($filename)) |
|---|
| | 267 | { |
|---|
| | 268 | $dir = sfConfig::get('sf_data_dir').DIRECTORY_SEPARATOR.'fixtures'; |
|---|
| | 269 | pake_mkdirs($dir); |
|---|
| | 270 | $filename = $dir.DIRECTORY_SEPARATOR.$filename; |
|---|
| | 271 | } |
|---|
| | 272 | |
|---|
| | 273 | pake_echo_action('propel', sprintf('dumping data to "%s"', $filename)); |
|---|
| | 274 | |
|---|
| | 275 | $data = new sfPropelData(); |
|---|
| | 276 | $data->dumpData($filename); |
|---|
| | 277 | } |
|---|
| | 278 | |
|---|
| | 279 | /** |
|---|
| | 280 | * Loads yml data from fixtures directory and inserts into database. |
|---|