Development

/branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php

You must first sign up to be able to contribute.

root/branches/1.1/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildAllLoadTask.class.php

Revision 8970, 2.6 kB (checked in by Carl.Vondrick, 7 years ago)

1.1: added cli option to skip building forms when using propel:build-all[-load] tasks to avoid cluttering lib/form (closes #3420)

  • 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__).'/sfPropelBaseTask.class.php');
12
13 /**
14  * Generates Propel model, SQL, initializes database, and load data.
15  *
16  * @package    symfony
17  * @subpackage command
18  * @author     Fabien Potencier <fabien.potencier@symfony-project.com>
19  * @version    SVN: $Id$
20  */
21 class sfPropelBuildAllLoadTask extends sfPropelBaseTask
22 {
23   /**
24    * @see sfTask
25    */
26   protected function configure()
27   {
28     $this->addArguments(array(
29       new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The application name'),
30     ));
31
32     $this->addOptions(array(
33       new sfCommandOption('env', null, sfCommandOption::PARAMETER_REQUIRED, 'The environment', 'dev'),
34       new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'),
35       new sfCommandOption('skip-forms', 'F', sfCommandOption::PARAMETER_NONE, 'Skip generating forms')
36     ));
37
38     $this->aliases = array('propel-build-all-load');
39     $this->namespace = 'propel';
40     $this->name = 'build-all-load';
41     $this->briefDescription = 'Generates Propel model, SQL, initializes database, and load data';
42
43     $this->detailedDescription = <<<EOF
44 The [propel:build-all-load|INFO] task is a shortcut for four other tasks:
45
46   [./symfony propel:build-all-load frontend|INFO]
47
48 The task is equivalent to:
49
50   [./symfony propel:build-all|INFO]
51   [./symfony propel:data-load frontend|INFO]
52
53 The task takes an application argument because of the [propel:data-load|COMMENT]
54 task. See [propel:data-load|COMMENT] help page for more information.
55 EOF;
56   }
57
58   /**
59    * @see sfTask
60    */
61   protected function execute($arguments = array(), $options = array())
62   {
63     // load Propel configuration before Phing
64     $databaseManager = new sfDatabaseManager($this->configuration);
65     require_once sfConfig::get('sf_symfony_lib_dir').'/plugins/sfPropelPlugin/lib/propel/sfPropelAutoload.php';
66
67     $buildAll = new sfPropelBuildAllTask($this->dispatcher, $this->formatter);
68     $buildAll->setCommandApplication($this->commandApplication);
69     $buildAll->run(array(), $options['skip-forms'] ? array('--skip-forms') : array());
70
71     $loadData = new sfPropelLoadDataTask($this->dispatcher, $this->formatter);
72     $loadData->setCommandApplication($this->commandApplication);
73
74     $loadData->run(array('application' => $arguments['application']), array('--env='.$options['env'], '--connection='.$options['connection']));
75   }
76 }
77
Note: See TracBrowser for help on using the browser.