| 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 sfDoctrineBuildAllTask extends sfDoctrineBaseTask |
|---|
| 24 |
{ |
|---|
| 25 |
|
|---|
| 26 |
* @see sfTask |
|---|
| 27 |
*/ |
|---|
| 28 |
protected function configure() |
|---|
| 29 |
{ |
|---|
| 30 |
$this->aliases = array('doctrine-build-all'); |
|---|
| 31 |
$this->namespace = 'doctrine'; |
|---|
| 32 |
$this->name = 'build-all'; |
|---|
| 33 |
$this->briefDescription = 'Generates Doctrine model, SQL and initializes the database'; |
|---|
| 34 |
|
|---|
| 35 |
$this->addOptions(array( |
|---|
| 36 |
new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), |
|---|
| 37 |
new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'), |
|---|
| 38 |
new sfCommandOption('no-confirmation', null, sfCommandOption::PARAMETER_NONE, 'Do not ask for confirmation'), |
|---|
| 39 |
new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms') |
|---|
| 40 |
)); |
|---|
| 41 |
|
|---|
| 42 |
$this->detailedDescription = <<<EOF |
|---|
| 43 |
The [doctrine:build-all|INFO] task is a shortcut for three other tasks: |
|---|
| 44 |
|
|---|
| 45 |
[./symfony doctrine:build-all|INFO] |
|---|
| 46 |
|
|---|
| 47 |
The task is equivalent to: |
|---|
| 48 |
|
|---|
| 49 |
[./symfony doctrine:build-model|INFO] |
|---|
| 50 |
[./symfony doctrine:build-sql|INFO] |
|---|
| 51 |
[./symfony doctrine:build-forms|INFO] |
|---|
| 52 |
[./symfony doctrine:insert-sql|INFO] |
|---|
| 53 |
|
|---|
| 54 |
See those three tasks help page for more information. |
|---|
| 55 |
|
|---|
| 56 |
To bypass the confirmation, you can pass the [no-confirmation|COMMENT] |
|---|
| 57 |
option: |
|---|
| 58 |
|
|---|
| 59 |
[./symfony doctrine:buil-all-load --no-confirmation|INFO] |
|---|
| 60 |
EOF; |
|---|
| 61 |
} |
|---|
| 62 |
|
|---|
| 63 |
|
|---|
| 64 |
* @see sfTask |
|---|
| 65 |
*/ |
|---|
| 66 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 67 |
{ |
|---|
| 68 |
$baseOptions = $this->configuration instanceof sfApplicationConfiguration ? array( |
|---|
| 69 |
'--application='.$this->configuration->getApplication(), |
|---|
| 70 |
'--env='.$options['env'], |
|---|
| 71 |
) : array(); |
|---|
| 72 |
|
|---|
| 73 |
$buildDb = new sfDoctrineBuildDbTask($this->dispatcher, $this->formatter); |
|---|
| 74 |
$buildDb->setCommandApplication($this->commandApplication); |
|---|
| 75 |
$ret = $buildDb->run(array(), $baseOptions); |
|---|
| 76 |
|
|---|
| 77 |
if ($ret) |
|---|
| 78 |
{ |
|---|
| 79 |
return $ret; |
|---|
| 80 |
} |
|---|
| 81 |
|
|---|
| 82 |
$buildModel = new sfDoctrineBuildModelTask($this->dispatcher, $this->formatter); |
|---|
| 83 |
$buildModel->setCommandApplication($this->commandApplication); |
|---|
| 84 |
$ret = $buildModel->run(array(), $baseOptions); |
|---|
| 85 |
|
|---|
| 86 |
if ($ret) |
|---|
| 87 |
{ |
|---|
| 88 |
return $ret; |
|---|
| 89 |
} |
|---|
| 90 |
|
|---|
| 91 |
$buildSql = new sfDoctrineBuildSqlTask($this->dispatcher, $this->formatter); |
|---|
| 92 |
$buildSql->setCommandApplication($this->commandApplication); |
|---|
| 93 |
$ret = $buildSql->run(array(), $baseOptions); |
|---|
| 94 |
|
|---|
| 95 |
if ($ret) |
|---|
| 96 |
{ |
|---|
| 97 |
return $ret; |
|---|
| 98 |
} |
|---|
| 99 |
|
|---|
| 100 |
if (!$options['skip-forms']) |
|---|
| 101 |
{ |
|---|
| 102 |
$buildForms = new sfDoctrineBuildFormsTask($this->dispatcher, $this->formatter); |
|---|
| 103 |
$buildForms->setCommandApplication($this->commandApplication); |
|---|
| 104 |
$ret = $buildForms->run(array(), $baseOptions); |
|---|
| 105 |
|
|---|
| 106 |
if ($ret) |
|---|
| 107 |
{ |
|---|
| 108 |
return $ret; |
|---|
| 109 |
} |
|---|
| 110 |
|
|---|
| 111 |
$buildFilters = new sfDoctrineBuildFiltersTask($this->dispatcher, $this->formatter); |
|---|
| 112 |
$buildFilters->setCommandApplication($this->commandApplication); |
|---|
| 113 |
$ret = $buildFilters->run(array(), $baseOptions); |
|---|
| 114 |
|
|---|
| 115 |
if ($ret) |
|---|
| 116 |
{ |
|---|
| 117 |
return $ret; |
|---|
| 118 |
} |
|---|
| 119 |
} |
|---|
| 120 |
|
|---|
| 121 |
$insertSql = new sfDoctrineInsertSqlTask($this->dispatcher, $this->formatter); |
|---|
| 122 |
$insertSql->setCommandApplication($this->commandApplication); |
|---|
| 123 |
$ret = $insertSql->run(array(), $baseOptions); |
|---|
| 124 |
|
|---|
| 125 |
return $ret; |
|---|
| 126 |
} |
|---|
| 127 |
} |
|---|