Development

/branches/1.2/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFiltersTask.class.php

You must first sign up to be able to contribute.

root/branches/1.2/lib/plugins/sfPropelPlugin/lib/task/sfPropelBuildFiltersTask.class.php

Revision 12537, 3.1 kB (checked in by fabien, 5 years ago)

[1.2] fixed autoloading in tasks (closes #4675, #4346)

  • 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 informationation, 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 filter form 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$
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     // customize php and yml files
81     $finder = sfFinder::type('file')->name('*.php');
82     $this->getFilesystem()->replaceTokens($finder->in(sfConfig::get('sf_lib_dir').'/filter/'), '##', '##', $constants);
83   }
84 }
85
Note: See TracBrowser for help on using the browser.