| 1 |
lars |
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 |
* Create classes for the current model.
|
|
|
15 |
*
|
|
|
16 |
* @package symfony
|
|
|
17 |
* @subpackage propel
|
|
|
18 |
* @author Fabien Potencier <fabien.potencier@symfony-project.com>
|
|
|
19 |
* @version SVN: $Id: sfPropelBuildModelTask.class.php 23922 2009-11-14 14:58:38Z fabien $
|
|
|
20 |
*/
|
|
|
21 |
class sfPropelBuildModelTask extends sfPropelBaseTask
|
|
|
22 |
{
|
|
|
23 |
/**
|
|
|
24 |
* @see sfTask
|
|
|
25 |
*/
|
|
|
26 |
protected function configure()
|
|
|
27 |
{
|
|
|
28 |
$this->addOptions(array(
|
|
|
29 |
new sfCommandOption('phing-arg', null, sfCommandOption::PARAMETER_REQUIRED | sfCommandOption::IS_ARRAY, 'Arbitrary phing argument'),
|
|
|
30 |
));
|
|
|
31 |
|
|
|
32 |
$this->namespace = 'propel';
|
|
|
33 |
$this->name = 'build-model';
|
|
|
34 |
$this->briefDescription = 'Creates classes for the current model';
|
|
|
35 |
|
|
|
36 |
$this->detailedDescription = <<<EOF
|
|
|
37 |
The [propel:build-model|INFO] task creates model classes from the schema:
|
|
|
38 |
|
|
|
39 |
[./symfony propel:build-model|INFO]
|
|
|
40 |
|
|
|
41 |
The task read the schema information in [config/*schema.xml|COMMENT] and/or
|
|
|
42 |
[config/*schema.yml|COMMENT] from the project and all installed plugins.
|
|
|
43 |
|
|
|
44 |
You mix and match YML and XML schema files. The task will convert
|
|
|
45 |
YML ones to XML before calling the Propel task.
|
|
|
46 |
|
|
|
47 |
The model classes files are created in [lib/model|COMMENT].
|
|
|
48 |
|
|
|
49 |
This task never overrides custom classes in [lib/model|COMMENT].
|
|
|
50 |
It only replaces files in [lib/model/om|COMMENT] and [lib/model/map|COMMENT].
|
|
|
51 |
EOF;
|
|
|
52 |
}
|
|
|
53 |
|
|
|
54 |
/**
|
|
|
55 |
* @see sfTask
|
|
|
56 |
*/
|
|
|
57 |
protected function execute($arguments = array(), $options = array())
|
|
|
58 |
{
|
|
|
59 |
$this->schemaToXML(self::DO_NOT_CHECK_SCHEMA, 'generated-');
|
|
|
60 |
$this->copyXmlSchemaFromPlugins('generated-');
|
|
|
61 |
$ret = $this->callPhing('om', self::CHECK_SCHEMA);
|
|
|
62 |
$this->cleanup();
|
|
|
63 |
|
|
|
64 |
$this->reloadAutoload();
|
|
|
65 |
|
|
|
66 |
return !$ret;
|
|
|
67 |
}
|
|
|
68 |
}
|