| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
class sfProjectEnableTask extends sfBaseTask |
|---|
| 20 |
{ |
|---|
| 21 |
|
|---|
| 22 |
* @see sfTask |
|---|
| 23 |
*/ |
|---|
| 24 |
protected function configure() |
|---|
| 25 |
{ |
|---|
| 26 |
$this->addArguments(array( |
|---|
| 27 |
new sfCommandArgument('env', sfCommandArgument::REQUIRED, 'The environment name'), |
|---|
| 28 |
new sfCommandArgument('app', sfCommandArgument::OPTIONAL | sfCommandArgument::IS_ARRAY, 'The application name'), |
|---|
| 29 |
)); |
|---|
| 30 |
|
|---|
| 31 |
$this->aliases = array('enable'); |
|---|
| 32 |
$this->namespace = 'project'; |
|---|
| 33 |
$this->name = 'enable'; |
|---|
| 34 |
$this->briefDescription = 'Enables an application in a given environment'; |
|---|
| 35 |
|
|---|
| 36 |
$this->detailedDescription = <<<EOF |
|---|
| 37 |
The [project:enable|INFO] task enables a specific environment: |
|---|
| 38 |
|
|---|
| 39 |
[./symfony project:enable frontend prod|INFO] |
|---|
| 40 |
|
|---|
| 41 |
You can also specify individual applications to be enabled in that |
|---|
| 42 |
environment: |
|---|
| 43 |
|
|---|
| 44 |
[./symfony project:enable prod frontend backend|INFO] |
|---|
| 45 |
EOF; |
|---|
| 46 |
} |
|---|
| 47 |
|
|---|
| 48 |
|
|---|
| 49 |
* @see sfTask |
|---|
| 50 |
*/ |
|---|
| 51 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 52 |
{ |
|---|
| 53 |
if (1 == count($arguments['app']) && !file_exists(sfConfig::get('sf_apps_dir').'/'.$arguments['app'][0])) |
|---|
| 54 |
{ |
|---|
| 55 |
|
|---|
| 56 |
$applications = array($arguments['env']); |
|---|
| 57 |
$env = $arguments['app'][0]; |
|---|
| 58 |
} |
|---|
| 59 |
else |
|---|
| 60 |
{ |
|---|
| 61 |
$applications = count($arguments['app']) ? $arguments['app'] : sfFinder::type('dir')->relative()->maxdepth(0)->in(sfConfig::get('sf_apps_dir')); |
|---|
| 62 |
$env = $arguments['env']; |
|---|
| 63 |
} |
|---|
| 64 |
|
|---|
| 65 |
foreach ($applications as $app) |
|---|
| 66 |
{ |
|---|
| 67 |
$lockFile = sfConfig::get('sf_data_dir').'/'.$app.'_'.$env.'.lck'; |
|---|
| 68 |
if (!file_exists($lockFile)) |
|---|
| 69 |
{ |
|---|
| 70 |
$this->logSection('enable', sprintf('%s [%s] is currently ENABLED', $app, $env)); |
|---|
| 71 |
} |
|---|
| 72 |
else |
|---|
| 73 |
{ |
|---|
| 74 |
$this->getFilesystem()->remove($lockFile); |
|---|
| 75 |
|
|---|
| 76 |
$clearCache = new sfCacheClearTask($this->dispatcher, $this->formatter); |
|---|
| 77 |
$clearCache->setCommandApplication($this->commandApplication); |
|---|
| 78 |
$clearCache->setConfiguration($this->configuration); |
|---|
| 79 |
$clearCache->run(array(), array('--app='.$app, '--env='.$env)); |
|---|
| 80 |
|
|---|
| 81 |
$this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env)); |
|---|
| 82 |
} |
|---|
| 83 |
} |
|---|
| 84 |
} |
|---|
| 85 |
} |
|---|
| 86 |
|
|---|