| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
|
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 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 |
|
|---|