Development

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

You must first sign up to be able to contribute.

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

Revision 23922, 2.5 kB (checked in by fabien, 5 years ago)

[1.4] removed deprecated stuff

  • 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->namespace = 'project';
32     $this->name = 'enable';
33     $this->briefDescription = 'Enables an application in a given environment';
34
35     $this->detailedDescription = <<<EOF
36 The [project:enable|INFO] task enables a specific environment:
37
38   [./symfony project:enable frontend prod|INFO]
39
40 You can also specify individual applications to be enabled in that
41 environment:
42
43   [./symfony project:enable 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 ENABLED', $app, $env));
70       }
71       else
72       {
73         $this->getFilesystem()->remove($lockFile);
74
75         $clearCache = new sfCacheClearTask($this->dispatcher, $this->formatter);
76         $clearCache->setCommandApplication($this->commandApplication);
77         $clearCache->setConfiguration($this->configuration);
78         $clearCache->run(array(), array('--app='.$app, '--env='.$env));
79
80         $this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env));
81       }
82     }
83   }
84 }
85
Note: See TracBrowser for help on using the browser.