| 1 |
<?php |
|---|
| 2 |
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 |
|
|---|
| 6 |
|
|---|
| 7 |
|
|---|
| 8 |
|
|---|
| 9 |
|
|---|
| 10 |
|
|---|
| 11 |
require_once(dirname(__FILE__).'/sfPropelBaseTask.class.php'); |
|---|
| 12 |
|
|---|
| 13 |
|
|---|
| 14 |
|
|---|
| 15 |
|
|---|
| 16 |
|
|---|
| 17 |
|
|---|
| 18 |
|
|---|
| 19 |
|
|---|
| 20 |
|
|---|
| 21 |
class sfPropelBuildFiltersTask extends sfPropelBaseTask |
|---|
| 22 |
{ |
|---|
| 23 |
|
|---|
| 24 |
* @see sfTask |
|---|
| 25 |
*/ |
|---|
| 26 |
protected function configure() |
|---|
| 27 |
{ |
|---|
| 28 |
$this->addOptions(array( |
|---|
| 29 |
new sfCommandOption('connection', null, sfCommandOption::PARAMETER_REQUIRED, 'The connection name', 'propel'), |
|---|
| 30 |
new sfCommandOption('model-dir-name', null, sfCommandOption::PARAMETER_REQUIRED, 'The model dir name', 'model'), |
|---|
| 31 |
new sfCommandOption('filter-dir-name', null, sfCommandOption::PARAMETER_REQUIRED, 'The filter form dir name', 'filter'), |
|---|
| 32 |
new sfCommandOption('application', null, sfCommandOption::PARAMETER_OPTIONAL, 'The application name', true), |
|---|
| 33 |
)); |
|---|
| 34 |
|
|---|
| 35 |
$this->namespace = 'propel'; |
|---|
| 36 |
$this->name = 'build-filters'; |
|---|
| 37 |
$this->briefDescription = 'Creates filter form classes for the current model'; |
|---|
| 38 |
|
|---|
| 39 |
$this->detailedDescription = <<<EOF |
|---|
| 40 |
The [propel:build-filters|INFO] task creates filter form classes from the schema: |
|---|
| 41 |
|
|---|
| 42 |
[./symfony propel:build-filters|INFO] |
|---|
| 43 |
|
|---|
| 44 |
The task read the schema information in [config/*schema.xml|COMMENT] and/or |
|---|
| 45 |
[config/*schema.yml|COMMENT] from the project and all installed plugins. |
|---|
| 46 |
|
|---|
| 47 |
The task use the [propel|COMMENT] connection as defined in [config/databases.yml|COMMENT]. |
|---|
| 48 |
You can use another connection by using the [--connection|COMMENT] option: |
|---|
| 49 |
|
|---|
| 50 |
[./symfony propel:build-filters --connection="name"|INFO] |
|---|
| 51 |
|
|---|
| 52 |
The model filter form classes files are created in [lib/filter|COMMENT]. |
|---|
| 53 |
|
|---|
| 54 |
This task never overrides custom classes in [lib/filter|COMMENT]. |
|---|
| 55 |
It only replaces base classes generated in [lib/filter/base|COMMENT]. |
|---|
| 56 |
EOF; |
|---|
| 57 |
} |
|---|
| 58 |
|
|---|
| 59 |
|
|---|
| 60 |
* @see sfTask |
|---|
| 61 |
*/ |
|---|
| 62 |
protected function execute($arguments = array(), $options = array()) |
|---|
| 63 |
{ |
|---|
| 64 |
$this->logSection('propel', 'generating filter form classes'); |
|---|
| 65 |
|
|---|
| 66 |
$generatorManager = new sfGeneratorManager($this->configuration); |
|---|
| 67 |
$generatorManager->generate('sfPropelFormFilterGenerator', array( |
|---|
| 68 |
'connection' => $options['connection'], |
|---|
| 69 |
'model_dir_name' => $options['model-dir-name'], |
|---|
| 70 |
'filter_dir_name' => $options['filter-dir-name'], |
|---|
| 71 |
)); |
|---|
| 72 |
|
|---|
| 73 |
$properties = parse_ini_file(sfConfig::get('sf_config_dir').DIRECTORY_SEPARATOR.'properties.ini', true); |
|---|
| 74 |
|
|---|
| 75 |
$constants = array( |
|---|
| 76 |
'PROJECT_NAME' => isset($properties['symfony']['name']) ? $properties['symfony']['name'] : 'symfony', |
|---|
| 77 |
'AUTHOR_NAME' => isset($properties['symfony']['author']) ? $properties['symfony']['author'] : 'Your name here' |
|---|
| 78 |
); |
|---|
| 79 |
|
|---|
| 80 |
|
|---|
| 81 |
$finder = sfFinder::type('file')->name('*.php'); |
|---|
| 82 |
$this->getFilesystem()->replaceTokens($finder->in(sfConfig::get('sf_lib_dir').'/filter/'), '##', '##', $constants); |
|---|
| 83 |
} |
|---|
| 84 |
} |
|---|
| 85 |
|
|---|