Development

/branches/1.2/lib/task/generator/sfGenerateProjectTask.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/task/generator/sfGenerateProjectTask.class.php

Revision 21897, 3.3 kB (checked in by fabien, 5 years ago)

[1.2, 1.3] fixed generate:project error message (closes #6807)

  • 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) 2004-2006 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 require_once(dirname(__FILE__).'/sfGeneratorBaseTask.class.php');
12
13 /**
14  * Generates a new project.
15  *
16  * @package    symfony
17  * @subpackage task
18  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
19  * @version    SVN: $Id$
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 symfony project already exists in this directory (%s).', getcwd()));
67     }
68
69     // create basic project structure
70     $finder = sfFinder::type('any')->discard('.sf');
71     $this->getFilesystem()->mirror(dirname(__FILE__).'/skeleton/project', sfConfig::get('sf_root_dir'), $finder);
72
73     // update project name and directory
74     $finder = sfFinder::type('file')->name('properties.ini', 'apache.conf', 'propel.ini', 'databases.yml');
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     // update ProjectConfiguration class
78     $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir').'/ProjectConfiguration.class.php', '##', '##', array('SYMFONY_LIB_DIR'  => sfConfig::get('sf_symfony_lib_dir')));
79
80     // update vhost sample file
81     $this->getFileSystem()->replaceTokens(sfConfig::get('sf_config_dir').'/vhost.sample', '##', '##', array('PROJECT_NAME' => $arguments['name'], 'SYMFONY_WEB_DIR' => sfConfig::get('sf_web_dir'), 'SYMFONY_SF_DIR' => realpath(sfCoreAutoload::getInstance()->getBaseDir().'../data/web/sf')));
82
83     // fix permission for common directories
84     $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter);
85     $fixPerms->setCommandApplication($this->commandApplication);
86     $fixPerms->run();
87
88     // publish assets for core plugins
89     $publishAssets = new sfPluginPublishAssetsTask($this->dispatcher, $this->formatter);
90     $publishAssets->setCommandApplication($this->commandApplication);
91     $publishAssets->run(array(), array('--core-only'));
92   }
93 }
94
Note: See TracBrowser for help on using the browser.