| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php'); |
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
class sfGenerateProjectTask extends sfGeneratorBaseTask |
|---|
| 22 |
{ |
|---|
| 23 |
|
|---|
| 24 |
* @see sfTask |
|---|
| 25 |
*/ |
|---|
| 26 |
protected function doRun(sfCommandManager $commandManager, $options) |
|---|
| 27 |
{ |
|---|
| 28 |
$this->process($commandManager, $options); |
|---|
| 29 |
|
|---|
| 30 |
return $this->execute($commandManager->getArgumentValues(), $commandManager->getOptionValues()); |
|---|
| 31 |
} |
|---|
| 32 |
|
|---|
| 33 |
|
|---|
| 34 |
* @see sfTask |
|---|
| 35 |
*/ |
|---|
| 36 |
protected function configure() |
|---|
| 37 |
{ |
|---|
| 38 |
$this->addArguments(array( |
|---|
| 39 |
new sfCommandArgument('name', sfCommandArgument::REQUIRED, 'The project name'), |
|---|
| 40 |
)); |
|---|
| 41 |
|
|---|
| 42 |
$this->aliases = array('init-project'); |
|---|
| 43 |
$this->namespace = 'generate'; |
|---|
| 44 |
$this->name = 'project'; |
|---|
| 45 |
|
|---|
| 46 |
$this->briefDescription = 'Generates a new project'; |
|---|
| 47 |
|
|---|
| 48 |
$this->detailedDescription = <<<EOF |
|---|
| 49 |
The [generate:project|INFO] task creates the basic directory structure |
|---|
| 50 |
for a new project in the current directory: |
|---|
| 51 |
|
|---|
| 52 |
[./symfony generate:project blog|INFO] |
|---|
| 53 |
|
|---|
| 54 |
If the current directory already contains a symfony project, |
|---|
| 55 |
it throws a [sfCommandException|COMMENT]. |
|---|
| 56 |
EOF; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* @see sfTask |
|---|
| 61 |
*/ |
|---|
| 62 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 63 |
{ |
|---|
| 64 |
if (file_exists('symfony')) |
|---|
| 65 |
{ |
|---|
| 66 |
throw new sfCommandException(sprintf('A project named "%s" already exists in this directory.', $arguments['name'])); |
|---|
| 67 |
} |
|---|
| 68 |
|
|---|
| 69 |
|
|---|
| 70 |
$finder = sfFinder::type('any')->discard('.sf'); |
|---|
| 71 |
$this->getFilesystem()->mirror(dirname(__FILE__).'/skeleton/project', sfConfig::get('sf_root_dir'), $finder); |
|---|
| 72 |
|
|---|
| 73 |
|
|---|
| 74 |
$finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini'); |
|---|
| 75 |
$this->getFileSystem()->replaceTokens($finder->in(sfConfig::get('sf_config_dir')), '##', '##', array('PROJECT_NAME' => $arguments['name'], 'PROJECT_DIR' => sfConfig::get('sf_root_dir'))); |
|---|
| 76 |
|
|---|
| 77 |
|
|---|
| 78 |
$this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir').'/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR' => sfConfig::get('sf_symfony_lib_dir'))); |
|---|
| 79 |
|
|---|
| 80 |
$fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter); |
|---|
| 81 |
$fixPerms->setCommandApplication($this->commandApplication); |
|---|
| 82 |
$fixPerms->run(); |
|---|
| 83 |
} |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|