sfProjectDisableTask.class.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  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. * Disables 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: sfProjectDisableTask.class.php 9890 2008-06-26 11:35:01Z fabien $
  16. */
  17. class sfProjectDisableTask 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('disable');
  29. $this->namespace = 'project';
  30. $this->name = 'disable';
  31. $this->briefDescription = 'Disables an application in a given environment';
  32. $this->detailedDescription = <<<EOF
  33. The [project:disable|INFO] task disables an application for a specific environment:
  34. [./symfony project:disable 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 DISABLED', $app, $env));
  48. }
  49. else
  50. {
  51. $this->getFilesystem()->touch($lockFile);
  52. $this->logSection('enable', sprintf('%s [%s] has been DISABLED', $app, $env));
  53. }
  54. }
  55. }