sfConfigureAuthorTask.class.php 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <?php
  2. /*
  3. * This file is part of the symfony package.
  4. * (c) 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. * Configures the main author of the project.
  11. *
  12. * @package symfony
  13. * @subpackage task
  14. * @author Fabien Potencier <fabien.potencier@symfony-project.com>
  15. * @version SVN: $Id: sfConfigureAuthorTask.class.php 6978 2008-01-06 18:53:47Z fabien $
  16. */
  17. class sfConfigureAuthorTask extends sfBaseTask
  18. {
  19. /**
  20. * @see sfTask
  21. */
  22. protected function configure()
  23. {
  24. $this->addArguments(array(
  25. new sfCommandArgument('author', sfCommandArgument::REQUIRED, 'The project author'),
  26. ));
  27. $this->namespace = 'configure';
  28. $this->name = 'author';
  29. $this->briefDescription = 'Configure project author';
  30. $this->detailedDescription = <<<EOF
  31. The [configure:author|INFO] task configures the author for a project:
  32. [./symfony configure:author "Fabien Potencier <fabien.potencier@symfony-project.com>"|INFO]
  33. The author is used by the generates to pre-configure the PHPDoc header for each generated file.
  34. The value is stored in [config/properties.ini].
  35. EOF;
  36. }
  37. /**
  38. * @see sfTask
  39. */
  40. protected function execute($arguments = array(), $options = array())
  41. {
  42. $file = sfConfig::get('sf_config_dir').'/properties.ini';
  43. $content = parse_ini_file($file, true);
  44. if (!isset($content['symfony']))
  45. {
  46. $content['symfony'] = array();
  47. }
  48. $content['symfony']['author'] = $arguments['author'];
  49. $ini = '';
  50. foreach ($content as $section => $values)
  51. {
  52. $ini .= sprintf("[%s]\n", $section);
  53. foreach ($values as $key => $value)
  54. {
  55. $ini .= sprintf(" %s=%s\n", $key, $value);
  56. }
  57. }
  58. file_put_contents($file, $ini);
  59. }
  60. }