| 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 |
|
|---|
| 25 |
class sfDoctrineBuildAllTask extends sfDoctrineBaseTask |
|---|
| 26 |
{ |
|---|
| 27 |
|
|---|
| 28 |
* @see sfTask |
|---|
| 29 |
*/ |
|---|
| 30 |
protected function configure() |
|---|
| 31 |
{ |
|---|
| 32 |
$this->addOptions(array( |
|---|
| 33 |
new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), |
|---|
| 34 |
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), |
|---|
| 35 |
new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), |
|---|
| 36 |
new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms'), |
|---|
| 37 |
new sfCommandOption('migrate', null, sfCommandOption::PARAMETER_NONE, 'Migrate instead of reset the database'), |
|---|
| 38 |
)); |
|---|
| 39 |
|
|---|
| 40 |
$this->aliases = array('doctrine-build-all'); |
|---|
| 41 |
$this->namespace = 'doctrine'; |
|---|
| 42 |
$this->name = 'build-all'; |
|---|
| 43 |
$this->briefDescription = 'Generates Doctrine model, SQL and initializes the database'; |
|---|
| 44 |
|
|---|
| 45 |
$this->detailedDescription = <<<EOF |
|---|
| 46 |
The [doctrine:build-all|INFO] task is a shortcut for four other tasks: |
|---|
| 47 |
|
|---|
| 48 |
[./symfony doctrine:build-all|INFO] |
|---|
| 49 |
|
|---|
| 50 |
The task is equivalent to: |
|---|
| 51 |
|
|---|
| 52 |
[./symfony doctrine:build-model|INFO] |
|---|
| 53 |
[./symfony doctrine:build-sql|INFO] |
|---|
| 54 |
[./symfony doctrine:build-forms|INFO] |
|---|
| 55 |
[./symfony doctrine:insert-sql|INFO] |
|---|
| 56 |
|
|---|
| 57 |
See those four tasks help page for more information. |
|---|
| 58 |
|
|---|
| 59 |
To bypass the confirmation, you can pass the [no-confirmation|COMMENT] |
|---|
| 60 |
option: |
|---|
| 61 |
|
|---|
| 62 |
[./symfony doctrine:buil-all-load --no-confirmation|INFO] |
|---|
| 63 |
|
|---|
| 64 |
Include the [--migrate|COMMENT] option if you would like to run your project's |
|---|
| 65 |
migrations rather than inserting the Doctrine SQL. |
|---|
| 66 |
|
|---|
| 67 |
[./symfony doctrine:build-all --migrate|INFO] |
|---|
| 68 |
|
|---|
| 69 |
This is equivalent to: |
|---|
| 70 |
|
|---|
| 71 |
[./symfony doctrine:build-model|INFO] |
|---|
| 72 |
[./symfony doctrine:build-sql|INFO] |
|---|
| 73 |
[./symfony doctrine:build-forms|INFO] |
|---|
| 74 |
[./symfony doctrine:migrate|INFO] |
|---|
| 75 |
EOF; |
|---|
| 76 |
} |
|---|
| 77 |
|
|---|
| 78 |
|
|---|
| 79 |
* @see sfTask |
|---|
| 80 |
*/ |
|---|
| 81 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 82 |
{ |
|---|
| 83 |
$task = new sfDoctrineBuildTask($this->dispatcher, $this->formatter); |
|---|
| 84 |
$task->setCommandApplication($this->commandApplication); |
|---|
| 85 |
$task->setConfiguration($this->configuration); |
|---|
| 86 |
$ret = $task->run(array(), array( |
|---|
| 87 |
'no-confirmation' => $options['no-confirmation'], |
|---|
| 88 |
'db' => true, |
|---|
| 89 |
'model' => true, |
|---|
| 90 |
'forms' => !$options['skip-forms'], |
|---|
| 91 |
'filters' => !$options['skip-forms'], |
|---|
| 92 |
'sql' => true, |
|---|
| 93 |
'and-migrate' => $options['migrate'], |
|---|
| 94 |
)); |
|---|
| 95 |
|
|---|
| 96 |
return $ret; |
|---|
| 97 |
} |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|