| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
require_once(dirname(__FILE__).'/sfDoctrineBaseTask.class.php'); |
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
|
|---|
| 22 |
|
|---|
| 23 |
|
|---|
| 24 |
class sfDoctrineReloadDataTask extends sfDoctrineBaseTask |
|---|
| 25 |
{ |
|---|
| 26 |
|
|---|
| 27 |
* @see sfTask |
|---|
| 28 |
*/ |
|---|
| 29 |
protected function configure() |
|---|
| 30 |
{ |
|---|
| 31 |
$this->addOptions(array( |
|---|
| 32 |
new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), |
|---|
| 33 |
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), |
|---|
| 34 |
new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), |
|---|
| 35 |
new sfCommandOption('dir', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'The directories to look for fixtures'), |
|---|
| 36 |
new sfCommandOption('migrate', null, sfCommandOption::PARAMETER_NONE, 'Migrate instead of reset the database'), |
|---|
| 37 |
new sfCommandOption('append', null, sfCommandOption::PARAMETER_NONE, 'Don\'t delete current data in the database'), |
|---|
| 38 |
)); |
|---|
| 39 |
|
|---|
| 40 |
$this->aliases = array('doctrine-reload-data'); |
|---|
| 41 |
$this->namespace = 'doctrine'; |
|---|
| 42 |
$this->name = 'reload-data'; |
|---|
| 43 |
|
|---|
| 44 |
$this->briefDescription = 'Reloads databases and fixtures for your project'; |
|---|
| 45 |
|
|---|
| 46 |
$this->detailedDescription = <<<EOF |
|---|
| 47 |
The [doctrine:reload-data|INFO] task drops the database, recreates it and loads |
|---|
| 48 |
fixtures: |
|---|
| 49 |
|
|---|
| 50 |
[php symfony doctrine:reload-data|INFO] |
|---|
| 51 |
|
|---|
| 52 |
The task is equivalent to: |
|---|
| 53 |
|
|---|
| 54 |
[./symfony doctrine:drop-db|INFO] |
|---|
| 55 |
[./symfony doctrine:build-db|INFO] |
|---|
| 56 |
[./symfony doctrine:insert-sql|INFO] |
|---|
| 57 |
[./symfony doctrine:data-load|INFO] |
|---|
| 58 |
EOF; |
|---|
| 59 |
} |
|---|
| 60 |
|
|---|
| 61 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 62 |
{ |
|---|
| 63 |
$task = new sfDoctrineBuildTask($this->dispatcher, $this->formatter); |
|---|
| 64 |
$task->setCommandApplication($this->commandApplication); |
|---|
| 65 |
$task->setConfiguration($this->configuration); |
|---|
| 66 |
$ret = $task->run(array(), array( |
|---|
| 67 |
'no-confirmation' => $options['no-confirmation'], |
|---|
| 68 |
'db' => true, |
|---|
| 69 |
'and-migrate' => $options['migrate'], |
|---|
| 70 |
'and-load' => $options['append'] ? false : (count($options['dir']) ? $options['dir'] : true), |
|---|
| 71 |
'and-append' => $options['append'] ? (count($options['dir']) ? $options['dir'] : true) : false, |
|---|
| 72 |
)); |
|---|
| 73 |
|
|---|
| 74 |
return $ret; |
|---|
| 75 |
} |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|