Author: Kris.Wallsmith
Date: 2010-02-20 17:02:12 +0100 (Sat, 20 Feb 2010)
New Revision: 28153
Added:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form_filter/
Modified:
plugins/sfTaskExtraPlugin/branches/1.3/README
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form_filter/form.class.php
plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl
Log:
[sfTaskExtraPlugin] added doctrine:build-app-filters task
Modified: plugins/sfTaskExtraPlugin/branches/1.3/README
===================================================================
--- plugins/sfTaskExtraPlugin/branches/1.3/README 2010-02-20 15:57:55 UTC
(rev 28152)
+++ plugins/sfTaskExtraPlugin/branches/1.3/README 2010-02-20 16:02:12 UTC
(rev 28153)
@@ -1,13 +1,14 @@
This plugin adds the following tasks to the symfony CLI:
- * `doctrine:build-app-forms`: Builds form classes in the application lib
directory
- * `generate:controller`: Generates a new front controller in the web
directory
- * `generate:plugin`: Generates a new plugin
- * `generate:plugin-module`: Generates a new module in a plugin
- * `generate:test`: Generates a new unit test stub script
- * `plugin:package`: Create a plugin PEAR package
- * `subversion:set-props`: Sets typical Subversion properties
- * `test:plugin`: Launches a plugin test suite
+ * `doctrine:build-app-filters`: Builds form filter classes in the
application lib directory
+ * `doctrine:build-app-forms`: Builds form classes in the application lib
directory
+ * `generate:controller`: Generates a new front controller in the web
directory
+ * `generate:plugin`: Generates a new plugin
+ * `generate:plugin-module`: Generates a new module in a plugin
+ * `generate:test`: Generates a new unit test stub script
+ * `plugin:package`: Create a plugin PEAR package
+ * `subversion:set-props`: Sets typical Subversion properties
+ * `test:plugin`: Launches a plugin test suite
Use the `symfony help` command for details on each task:
Copied:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
(from rev 28152,
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php)
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
(rev 0)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
2010-02-20 16:02:12 UTC (rev 28153)
@@ -0,0 +1,79 @@
+<?php
+
+require_once dirname(__FILE__).'/sfTaskExtraDoctrineBaseTask.class.php';
+
+/**
+ * Builds form filter classes in the application lib directory.
+ *
+ * @package sfTaskExtraPlugin
+ * @subpackage task
+ * @author Kris Wallsmith <[email protected]>
+ * @version SVN: $Id$
+ */
+class sfDoctrineBuildAppFiltersTask extends sfTaskExtraDoctrineBaseTask
+{
+ /**
+ * @see sfTask
+ */
+ protected function configure()
+ {
+ $this->addArguments(array(
+ new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The
application name'),
+ ));
+
+ $this->namespace = 'doctrine';
+ $this->name = 'build-app-filters';
+
+ $this->briefDescription = 'Builds form filter classes in the application
lib directory';
+ }
+
+ /**
+ * @see sfTask
+ */
+ protected function execute($arguments = array(), $options = array())
+ {
+ $databaseManager = new sfDatabaseManager($this->configuration);
+
+ $this->checkAppExists($arguments['application']);
+
+ // load models
+ Doctrine_Core::loadModels($this->configuration->getModelDirs());
+ $models = Doctrine_Core::getLoadedModels();
+ $models = Doctrine_Core::initializeModels($models);
+ $models = Doctrine_Core::filterInvalidModels($models);
+
+ // skeleton directory
+ if
(is_readable(sfConfig::get('sf_data_dir').'/skeleton/doctrine_app_form_filter'))
+ {
+ $skeletonDir =
sfConfig::get('sf_data_dir').'/skeleton/doctrine_app_form_filter';
+ }
+ else
+ {
+ $skeletonDir = dirname(__FILE__).'/skeleton/app_form_filter';
+ }
+
+ // target directory
+ if (!file_exists($file =
sfConfig::get('sf_app_lib_dir').'/filter/doctrine'))
+ {
+ $this->getFilesystem()->mkdirs($file);
+ }
+
+ // constants
+ $properties =
parse_ini_file(sfConfig::get('sf_config_dir').'/properties.ini', true);
+ $constants = array(
+ 'PROJECT' => isset($properties['symfony']['name']) ?
$properties['symfony']['name'] : 'symfony',
+ 'AUTHOR' => isset($properties['symfony']['author']) ?
$properties['symfony']['author'] : 'Your name here',
+ 'APPLICATION' => $arguments['application'],
+ );
+
+ foreach ($models as $model)
+ {
+ $file =
sfConfig::get('sf_app_lib_dir').'/filter/doctrine/'.$arguments['application'].$model.'FormFilter.class.php';
+ if (class_exists($model.'FormFilter') && !file_exists($file))
+ {
+ $this->getFilesystem()->copy($skeletonDir.'/form.class.php', $file);
+ $this->getFilesystem()->replaceTokens($file, '##', '##', $constants +
array('MODEL' => $model));
+ }
+ }
+ }
+}
Modified:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form_filter/form.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form/form.class.php
2010-02-20 15:57:55 UTC (rev 28152)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form_filter/form.class.php
2010-02-20 16:02:12 UTC (rev 28153)
@@ -1,14 +1,14 @@
<?php
/**
- * ##MODEL## form class for the ##APPLICATION## application.
+ * ##MODEL## form filter class for the ##APPLICATION## application.
*
* @package ##PROJECT##
- * @subpackage form
+ * @subpackage filter
* @author ##AUTHOR##
* @version SVN: $Id$
*/
-class ##APPLICATION####MODEL##Form extends ##MODEL##Form
+class ##APPLICATION####MODEL##FormFilter extends ##MODEL##FormFilter
{
/**
* @see sfForm
Modified: plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl
===================================================================
--- plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl 2010-02-20
15:57:55 UTC (rev 28152)
+++ plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl 2010-02-20
16:02:12 UTC (rev 28153)
@@ -129,7 +129,7 @@
<date>soon</date>
<notes>
* Fixed bug when generating a test stub for a class in a plugin with
no test directory
- * Added `doctrine:build-app-forms` task
+ * Added `doctrine:build-app-forms` and `doctrine:build-app-filters`
tasks
</notes>
</release>
</changelog>
--
You received this message because you are subscribed to the Google Groups
"symfony SVN" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/symfony-svn?hl=en.