| 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 sfDoctrineInsertSqlTask 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 |
)); |
|---|
| 34 |
|
|---|
| 35 |
$this->namespace = 'doctrine'; |
|---|
| 36 |
$this->name = 'insert-sql'; |
|---|
| 37 |
$this->briefDescription = 'Inserts SQL for current model'; |
|---|
| 38 |
|
|---|
| 39 |
$this->detailedDescription = <<<EOF |
|---|
| 40 |
The [doctrine:insert-sql|INFO] task creates database tables: |
|---|
| 41 |
|
|---|
| 42 |
[./symfony doctrine:insert-sql|INFO] |
|---|
| 43 |
|
|---|
| 44 |
The task connects to the database and creates tables for all the |
|---|
| 45 |
[lib/model/doctrine/*.class.php|COMMENT] files. |
|---|
| 46 |
EOF; |
|---|
| 47 |
} |
|---|
| 48 |
|
|---|
| 49 |
|
|---|
| 50 |
* @see sfTask |
|---|
| 51 |
*/ |
|---|
| 52 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 53 |
{ |
|---|
| 54 |
$this->logSection('doctrine', 'creating tables'); |
|---|
| 55 |
|
|---|
| 56 |
$databaseManager = new sfDatabaseManager($this->configuration); |
|---|
| 57 |
$config = $this->getCliConfig(); |
|---|
| 58 |
|
|---|
| 59 |
Doctrine_Core::loadModels($config['models_path'], Doctrine_Core::MODEL_LOADING_CONSERVATIVE); |
|---|
| 60 |
Doctrine_Core::createTablesFromArray(Doctrine_Core::getLoadedModels()); |
|---|
| 61 |
|
|---|
| 62 |
$this->logSection('doctrine', 'created tables successfully'); |
|---|
| 63 |
} |
|---|
| 64 |
} |
|---|
| 65 |
|
|---|