| 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 |
class sfDoctrineRebuildDbTask extends sfDoctrineBaseTask |
|---|
| 24 |
{ |
|---|
| 25 |
|
|---|
| 26 |
* @see sfTask |
|---|
| 27 |
*/ |
|---|
| 28 |
protected function configure() |
|---|
| 29 |
{ |
|---|
| 30 |
$this->addOptions(array( |
|---|
| 31 |
new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), |
|---|
| 32 |
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), |
|---|
| 33 |
new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Whether to no-confirmation dropping of the database') |
|---|
| 34 |
)); |
|---|
| 35 |
|
|---|
| 36 |
$this->aliases = array('doctrine-rebuild-db'); |
|---|
| 37 |
$this->namespace = 'doctrine'; |
|---|
| 38 |
$this->name = 'rebuild-db'; |
|---|
| 39 |
$this->briefDescription = 'Creates database for current model'; |
|---|
| 40 |
|
|---|
| 41 |
$this->detailedDescription = <<<EOF |
|---|
| 42 |
The [doctrine:rebuild-db|INFO] task creates the database: |
|---|
| 43 |
|
|---|
| 44 |
[./symfony doctrine:rebuild-db|INFO] |
|---|
| 45 |
|
|---|
| 46 |
The task read connection information in [config/doctrine/databases.yml|COMMENT]: |
|---|
| 47 |
EOF; |
|---|
| 48 |
} |
|---|
| 49 |
|
|---|
| 50 |
|
|---|
| 51 |
* @see sfTask |
|---|
| 52 |
*/ |
|---|
| 53 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 54 |
{ |
|---|
| 55 |
$baseOptions = $this->configuration instanceof sfApplicationConfiguration ? array( |
|---|
| 56 |
'--application='.$this->configuration->getApplication(), |
|---|
| 57 |
'--env='.$options['env'], |
|---|
| 58 |
) : array(); |
|---|
| 59 |
|
|---|
| 60 |
$dropDbOptions = $baseOptions; |
|---|
| 61 |
if (isset($options['no-confirmation']) && $options['no-confirmation']) |
|---|
| 62 |
{ |
|---|
| 63 |
$dropDbOptions[] = '--no-confirmation'; |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|
| 66 |
$dropDb = new sfDoctrineDropDbTask($this->dispatcher, $this->formatter); |
|---|
| 67 |
$dropDb->setCommandApplication($this->commandApplication); |
|---|
| 68 |
$dropDb->run(array(), $dropDbOptions); |
|---|
| 69 |
|
|---|
| 70 |
$buildAll = new sfDoctrineBuildAllTask($this->dispatcher, $this->formatter); |
|---|
| 71 |
$buildAll->setCommandApplication($this->commandApplication); |
|---|
| 72 |
$buildAll->run(array(), $baseOptions); |
|---|
| 73 |
} |
|---|
| 74 |
} |
|---|