Development

/branches/1.3/lib/task/project/sfProjectEnableTask.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/task/project/sfProjectEnableTask.class.php

Revision 20862, 2.5 kB (checked in by Kris.Wallsmith, 5 years ago)

[1.3] updated project:disable and project:enable tasks to allow execution on all applications in a given environment

  • Property svn:mime-type set to text/x-php
  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
Line 
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  * Enables 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$
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       // support previous task signature
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
Note: See TracBrowser for help on using the browser.