Development

/branches/1.3/lib/task/configure/sfConfigureAuthorTask.class.php

You must first sign up to be able to contribute.

root/branches/1.3/lib/task/configure/sfConfigureAuthorTask.class.php

Revision 6978, 1.8 kB (checked in by fabien, 6 years ago)

added a configure:author task

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