Development

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

You must first sign up to be able to contribute.

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

Revision 15155, 1.9 kB (checked in by FabianLange, 6 years ago)

[1.1] fixed project:enable task to clear only cache of the given application and environment. fixes #5750

  • 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('application', sfCommandArgument::REQUIRED, 'The application name'),
28       new sfCommandArgument('env', sfCommandArgument::REQUIRED, 'The environment 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 an application for a specific environment:
38
39   [./symfony project:enable frontend prod|INFO]
40 EOF;
41   }
42
43   /**
44    * @see sfTask
45    */
46   protected function execute($arguments = array(), $options = array())
47   {
48     $app = $arguments['application'];
49     $env = $arguments['env'];
50
51     $lockFile = sfConfig::get('sf_data_dir').'/'.$app.'_'.$env.'.lck';
52     if (!file_exists($lockFile))
53     {
54       $this->logSection('enable', sprintf('%s [%s] is currently ENABLED', $app, $env));
55     }
56     else
57     {
58       $this->getFilesystem()->remove($lockFile);
59
60       $clearCache = new sfCacheClearTask($this->dispatcher, $this->formatter);
61       $clearCache->setCommandApplication($this->commandApplication);
62       $clearCache->run(array(), array('--app='.$app, '--env='.$env));
63
64       $this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env));
65     }
66   }
67 }
68
Note: See TracBrowser for help on using the browser.