| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/*
|
|
|
4 |
* This file is part of the symfony package.
|
|
|
5 |
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
6 |
*
|
|
|
7 |
* For the full copyright and license information, please view the LICENSE
|
|
|
8 |
* file that was distributed with this source code.
|
|
|
9 |
*/
|
|
|
10 |
|
|
|
11 |
/**
|
|
|
12 |
* Disables an application in a given environment.
|
|
|
13 |
*
|
|
|
14 |
* @package symfony
|
|
|
15 |
* @subpackage task
|
|
|
16 |
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
17 |
* @version SVN: $Id: sfProjectDisableTask.class.php 23922 2009-11-14 14:58:38Z fabien $
|
|
|
18 |
*/
|
|
|
19 |
class sfProjectDisableTask 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->namespace = 'project';
|
|
|
32 |
$this->name = 'disable';
|
|
|
33 |
$this->briefDescription = 'Disables an application in a given environment';
|
|
|
34 |
|
|
|
35 |
$this->detailedDescription = <<<EOF
|
|
|
36 |
The [project:disable|INFO] task disables an environment:
|
|
|
37 |
|
|
|
38 |
[./symfony project:disable prod|INFO]
|
|
|
39 |
|
|
|
40 |
You can also specify individual applications to be disabled in that
|
|
|
41 |
environment:
|
|
|
42 |
|
|
|
43 |
[./symfony project:disable prod frontend backend|INFO]
|
|
|
44 |
EOF;
|
|
|
45 |
}
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* @see sfTask
|
|
|
49 |
*/
|
|
|
50 |
protected function execute($arguments = array(), $options = array())
|
|
|
51 |
{
|
|
|
52 |
if (1 == count($arguments['app']) && !file_exists(sfConfig::get('sf_apps_dir').'/'.$arguments['app'][0]))
|
|
|
53 |
{
|
|
|
54 |
// support previous task signature
|
|
|
55 |
$applications = array($arguments['env']);
|
|
|
56 |
$env = $arguments['app'][0];
|
|
|
57 |
}
|
|
|
58 |
else
|
|
|
59 |
{
|
|
|
60 |
$applications = count($arguments['app']) ? $arguments['app'] : sfFinder::type('dir')->relative()->maxdepth(0)->in(sfConfig::get('sf_apps_dir'));
|
|
|
61 |
$env = $arguments['env'];
|
|
|
62 |
}
|
|
|
63 |
|
|
|
64 |
foreach ($applications as $app)
|
|
|
65 |
{
|
|
|
66 |
$lockFile = sfConfig::get('sf_data_dir').'/'.$app.'_'.$env.'.lck';
|
|
|
67 |
if (file_exists($lockFile))
|
|
|
68 |
{
|
|
|
69 |
$this->logSection('enable', sprintf('%s [%s] is currently DISABLED', $app, $env));
|
|
|
70 |
}
|
|
|
71 |
else
|
|
|
72 |
{
|
|
|
73 |
$this->getFilesystem()->touch($lockFile);
|
|
|
74 |
|
|
|
75 |
$this->logSection('enable', sprintf('%s [%s] has been DISABLED', $app, $env));
|
|
|
76 |
}
|
|
|
77 |
}
|
|
|
78 |
}
|
|
|
79 |
}
|