Development

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

You must first sign up to be able to contribute.

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

Revision 8148, 2.6 kB (checked in by fabien, 7 years ago)

made sfFinder::ignore_version_control the default (you can disable it by calling ignore_version_control(false)) (refs #2795)

  • 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 project named "%s" already exists in this directory.', $arguments['name']));
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');
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     $fixPerms = new sfProjectPermissionsTask($this->dispatcher, $this->formatter);
81     $fixPerms->setCommandApplication($this->commandApplication);
82     $fixPerms->run();
83   }
84 }
85
Note: See TracBrowser for help on using the browser.