sfProjectEnableTask.class.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
  5. *
  6. * For the full copyright and license information, please view the LICENSE
  7. * file that was distributed with this source code.
  8. */
  9. /**
  10. * Enables an application in a given environment.
  11. *
  12. * @package symfony
  13. * @subpackage task
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfProjectEnableTask.class.php 15156 2009-01-31 21:44:54Z FabianLange $
  16. */
  17. class sfProjectEnableTask extends sfBaseTask
  18. {
  19. /**
  20. * @see sfTask
  21. */
  22. protected function configure()
  23. {
  24. $this->addArguments(array(
  25. new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'),
  26. new sfCommandArgument('env', sfCommandArgument::REQUIRED, 'The environment name'),
  27. ));
  28. $this->aliases = array('enable');
  29. $this->namespace = 'project';
  30. $this->name = 'enable';
  31. $this->briefDescription = 'Enables an application in a given environment';
  32. $this->detailedDescription = <<<EOF
  33. The [project:enable|INFO] task enables an application for a specific environment:
  34. [./symfony project:enable frontend prod|INFO]
  35. EOF;
  36. }
  37. /**
  38. * @see sfTask
  39. */
  40. protected function execute($arguments = array(), $options = array())
  41. {
  42. $app = $arguments['application'];
  43. $env = $arguments['env'];
  44. $lockFile = sfConfig::get('sf_data_dir').'/'.$app.'_'.$env.'.lck';
  45. if (!file_exists($lockFile))
  46. {
  47. $this->logSection('enable', sprintf('%s [%s] is currently ENABLED', $app, $env));
  48. }
  49. else
  50. {
  51. $this->getFilesystem()->remove($lockFile);
  52. $clearCache = new sfCacheClearTask($this->dispatcher, $this->formatter);
  53. $clearCache->setCommandApplication($this->commandApplication);
  54. $clearCache->run(array(), array('--app='.$app, '--env='.$env));
  55. $this->logSection('enable', sprintf('%s [%s] has been ENABLED', $app, $env));
  56. }
  57. }
  58. }