Author: Kris.Wallsmith
Date: 2010-02-22 17:53:57 +0100 (Mon, 22 Feb 2010)
New Revision: 28187
Added:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFiltersTask.class.php
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFormsTask.class.php
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfTaskExtraPropelBaseTask.class.php
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form/
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form/form.class.php
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form_filter/
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form_filter/form.class.php
Modified:
plugins/sfTaskExtraPlugin/branches/1.3/README
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl
Log:
[sfTaskExtraPlugin] added propel:build-app-forms and propel:build-app-filters
tasks
Modified: plugins/sfTaskExtraPlugin/branches/1.3/README
===================================================================
--- plugins/sfTaskExtraPlugin/branches/1.3/README 2010-02-22 14:45:05 UTC
(rev 28186)
+++ plugins/sfTaskExtraPlugin/branches/1.3/README 2010-02-22 16:53:57 UTC
(rev 28187)
@@ -1,15 +1,36 @@
This plugin adds the following tasks to the symfony CLI:
+Doctrine
+--------
+
* `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:
+Generator
+---------
- $ php symfony help generate:controller
+ * `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
+------
+
+ * `plugin:package`: Create a plugin PEAR package
+
+Propel
+------
+
+ * `propel:build-app-filters`: Builds form filter classes in the application
lib directory
+ * `propel:build-app-forms`: Builds form classes in the application lib
directory
+
+Subversion
+----------
+
+ * `subversion:set-props`: Sets typical Subversion properties
+
+Test
+----
+
+ * `test:plugin`: Launches a plugin test suite
Modified:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
2010-02-22 14:45:05 UTC (rev 28186)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFiltersTask.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -1,5 +1,10 @@
<?php
+if (!in_array('sfDoctrinePlugin',
sfProjectConfiguration::getActive()->getPlugins()))
+{
+ return false;
+}
+
require_once dirname(__FILE__).'/sfTaskExtraDoctrineBaseTask.class.php';
/**
@@ -25,6 +30,26 @@
$this->name = 'build-app-filters';
$this->briefDescription = 'Builds form filter classes in the application
lib directory';
+
+ $this->detailedDescription = <<<EOF
+The [doctrine:build-app-filters|INFO] task generates extensions of model form
+filters in an application's [lib/filter/doctrine/|COMMENT] directory:
+
+ [php symfony doctrine:build-app-filters frontend|INFO]
+
+The generated stub classes will be named in the format
[%app%%model%FormFilter|COMMENT]
+and will extend the stub form classes generated by the
[doctrine:build-filters|COMMENT]
+task. For example, [frontendArticleFormFilter|COMMENT] may be generated, which
would
+extend [ArticleFormFilter|COMMENT].
+
+You can provide a custom skeleton for this task by creating the following
+directory structure in your project:
+
+ data/
+ skeleton/
+ doctrine_app_form_filter/
+ form.class.php
+EOF;
}
/**
@@ -36,12 +61,6 @@
$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'))
{
@@ -66,7 +85,7 @@
'APPLICATION' => $arguments['application'],
);
- foreach ($models as $model)
+ foreach ($this->loadModels() 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))
@@ -75,5 +94,7 @@
$this->getFilesystem()->replaceTokens($file, '##', '##', $constants +
array('MODEL' => $model));
}
}
+
+ $this->reloadAutoload();
}
}
Modified:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
2010-02-22 14:45:05 UTC (rev 28186)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -1,5 +1,10 @@
<?php
+if (!in_array('sfDoctrinePlugin',
sfProjectConfiguration::getActive()->getPlugins()))
+{
+ return false;
+}
+
require_once dirname(__FILE__).'/sfTaskExtraDoctrineBaseTask.class.php';
/**
@@ -25,6 +30,26 @@
$this->name = 'build-app-forms';
$this->briefDescription = 'Builds form classes in the application lib
directory';
+
+ $this->detailedDescription = <<<EOF
+The [doctrine:build-app-forms|INFO] task generates extensions of model forms in
+an application's [lib/form/doctrine/|COMMENT] directory:
+
+ [php symfony doctrine:build-app-forms frontend|INFO]
+
+The generated stub classes will be named in the format
[%app%%model%Form|COMMENT]
+and will extend the stub form classes generated by the
[doctrine:build-forms|COMMENT]
+task. For example, [frontendArticleForm|COMMENT] may be generated, which would
extend
+[ArticleForm|COMMENT].
+
+You can provide a custom skeleton for this task by creating the following
+directory structure in your project:
+
+ data/
+ skeleton/
+ doctrine_app_form/
+ form.class.php
+EOF;
}
/**
@@ -36,12 +61,6 @@
$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'))
{
@@ -66,7 +85,7 @@
'APPLICATION' => $arguments['application'],
);
- foreach ($models as $model)
+ foreach ($this->loadModels() as $model)
{
$file =
sfConfig::get('sf_app_lib_dir').'/form/doctrine/'.$arguments['application'].$model.'Form.class.php';
if (class_exists($model.'Form') && !file_exists($file))
@@ -75,5 +94,7 @@
$this->getFilesystem()->replaceTokens($file, '##', '##', $constants +
array('MODEL' => $model));
}
}
+
+ $this->reloadAutoload();
}
}
Modified:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
2010-02-22 14:45:05 UTC (rev 28186)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -1,6 +1,9 @@
<?php
-require_once dirname(__FILE__).'/../sfTaskExtraBaseTask.class.php';
+if (!in_array('sfDoctrinePlugin',
sfProjectConfiguration::getActive()->getPlugins()))
+{
+ return false;
+}
/**
* Base Doctrine task.
@@ -12,4 +15,19 @@
*/
abstract class sfTaskExtraDoctrineBaseTask extends sfDoctrineBaseTask
{
+ /**
+ * Loads all model classes and returns an array of model names.
+ *
+ * @return array An array of model names
+ */
+ protected function loadModels()
+ {
+ Doctrine_Core::loadModels($this->configuration->getModelDirs());
+
+ $models = Doctrine_Core::getLoadedModels();
+ $models = Doctrine_Core::initializeModels($models);
+ $models = Doctrine_Core::filterInvalidModels($models);
+
+ return $models;
+ }
}
Added:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFiltersTask.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFiltersTask.class.php
(rev 0)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFiltersTask.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -0,0 +1,98 @@
+<?php
+
+if (!in_array('sfPropelPlugin',
sfProjectConfiguration::getActive()->getPlugins()))
+{
+ return false;
+}
+
+require_once dirname(__FILE__).'/sfTaskExtraPropelBaseTask.class.php';
+
+/**
+ * Builds form filter classes in the application lib directory.
+ *
+ * @package sfTaskExtraPlugin
+ * @subpackage task
+ * @author Kris Wallsmith <[email protected]>
+ * @version SVN: $Id$
+ */
+class sfPropelBuildAppFiltersTask extends sfTaskExtraPropelBaseTask
+{
+ /**
+ * @see sfTask
+ */
+ protected function configure()
+ {
+ $this->addArguments(array(
+ new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The
application name'),
+ ));
+
+ $this->namespace = 'propel';
+ $this->name = 'build-app-filters';
+
+ $this->briefDescription = 'Builds form filter classes in the application
lib directory';
+
+ $this->detailedDescription = <<<EOF
+The [propel:build-app-filters|INFO] task generates extensions of model form
+filters in an application's [lib/filter/|COMMENT] directory:
+
+ [php symfony propel:build-app-filters frontend|INFO]
+
+The generated stub classes will be named in the format
[%app%%model%FormFilter|COMMENT]
+and will extend the stub form classes generated by the
[propel:build-filters|COMMENT]
+task. For example, [frontendArticleFormFilter|COMMENT] may be generated, which
would
+extend [ArticleFormFilter|COMMENT].
+
+You can provide a custom skeleton for this task by creating the following
+directory structure in your project:
+
+ data/
+ skeleton/
+ propel_app_form_filter/
+ form.class.php
+EOF;
+ }
+
+ /**
+ * @see sfTask
+ */
+ protected function execute($arguments = array(), $options = array())
+ {
+ $this->checkAppExists($arguments['application']);
+
+ // skeleton directory
+ if
(is_readable(sfConfig::get('sf_data_dir').'/skeleton/propel_app_form_filter'))
+ {
+ $skeletonDir =
sfConfig::get('sf_data_dir').'/skeleton/propel_app_form_filter';
+ }
+ else
+ {
+ $skeletonDir = dirname(__FILE__).'/skeleton/app_form_filter';
+ }
+
+ // target directory
+ if (!file_exists($file = sfConfig::get('sf_app_lib_dir').'/filter'))
+ {
+ $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 ($this->loadModels() as $model)
+ {
+ $file =
sfConfig::get('sf_app_lib_dir').'/filter/'.$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));
+ }
+ }
+
+ $this->reloadAutoload();
+ }
+}
Property changes on:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFiltersTask.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFormsTask.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFormsTask.class.php
(rev 0)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFormsTask.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -0,0 +1,98 @@
+<?php
+
+if (!in_array('sfPropelPlugin',
sfProjectConfiguration::getActive()->getPlugins()))
+{
+ return false;
+}
+
+require_once dirname(__FILE__).'/sfTaskExtraPropelBaseTask.class.php';
+
+/**
+ * Builds form classes in the application lib directory.
+ *
+ * @package sfTaskExtraPlugin
+ * @subpackage task
+ * @author Kris Wallsmith <[email protected]>
+ * @version SVN: $Id$
+ */
+class sfPropelBuildAppFormsTask extends sfTaskExtraPropelBaseTask
+{
+ /**
+ * @see sfTask
+ */
+ protected function configure()
+ {
+ $this->addArguments(array(
+ new sfCommandArgument('application', sfCommandArgument::REQUIRED, 'The
application name'),
+ ));
+
+ $this->namespace = 'propel';
+ $this->name = 'build-app-forms';
+
+ $this->briefDescription = 'Builds form classes in the application lib
directory';
+
+ $this->detailedDescription = <<<EOF
+The [propel:build-app-forms|INFO] task generates extensions of model forms in
+an application's [lib/form/|COMMENT] directory:
+
+ [php symfony propel:build-app-forms frontend|INFO]
+
+The generated stub classes will be named in the format
[%app%%model%Form|COMMENT]
+and will extend the stub form classes generated by the
[propel:build-forms|COMMENT]
+task. For example, [frontendArticleForm|COMMENT] may be generated, which would
extend
+[ArticleForm|COMMENT].
+
+You can provide a custom skeleton for this task by creating the following
+directory structure in your project:
+
+ data/
+ skeleton/
+ propel_app_form/
+ form.class.php
+EOF;
+ }
+
+ /**
+ * @see sfTask
+ */
+ protected function execute($arguments = array(), $options = array())
+ {
+ $this->checkAppExists($arguments['application']);
+
+ // skeleton directory
+ if (is_readable(sfConfig::get('sf_data_dir').'/skeleton/propel_app_form'))
+ {
+ $skeletonDir = sfConfig::get('sf_data_dir').'/skeleton/propel_app_form';
+ }
+ else
+ {
+ $skeletonDir = dirname(__FILE__).'/skeleton/app_form';
+ }
+
+ // target directory
+ if (!file_exists($file = sfConfig::get('sf_app_lib_dir').'/form'))
+ {
+ $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 ($this->loadModels() as $model)
+ {
+ $file =
sfConfig::get('sf_app_lib_dir').'/form/'.$arguments['application'].$model.'Form.class.php';
+ if (class_exists($model.'Form') && !file_exists($file))
+ {
+ $this->getFilesystem()->copy($skeletonDir.'/form.class.php', $file);
+ $this->getFilesystem()->replaceTokens($file, '##', '##', $constants +
array('MODEL' => $model));
+ }
+ }
+
+ $this->reloadAutoload();
+ }
+}
Property changes on:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfPropelBuildAppFormsTask.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfTaskExtraPropelBaseTask.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfTaskExtraPropelBaseTask.class.php
(rev 0)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfTaskExtraPropelBaseTask.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -0,0 +1,40 @@
+<?php
+
+if (!in_array('sfPropelPlugin',
sfProjectConfiguration::getActive()->getPlugins()))
+{
+ return false;
+}
+
+/**
+ * Base Propel task.
+ *
+ * @package sfTaskExtraPlugin
+ * @subpackage task
+ * @author Kris Wallsmith <[email protected]>
+ * @version SVN: $Id$
+ */
+abstract class sfTaskExtraPropelBaseTask extends sfPropelBaseTask
+{
+ /**
+ * Loads all model classes and returns an array of model names.
+ *
+ * @return array An array of model names
+ */
+ protected function loadModels()
+ {
+ $models = array();
+
+ $finder = sfFinder::type('file')->name('*TableMap.php');
+ foreach ($finder->in($this->configuration->getModelDirs()) as $file)
+ {
+ $model = basename($file, 'TableMap.php');
+ if (class_exists($model) && is_subclass_of($model, 'BaseObject'))
+ {
+ Propel::getDatabaseMap()->addTableFromMapClass(basename($file,
'.php'));
+ $models[] = $model;
+ }
+ }
+
+ return $models;
+ }
+}
Property changes on:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/sfTaskExtraPropelBaseTask.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form/form.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form/form.class.php
(rev 0)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form/form.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * ##MODEL## form class for the ##APPLICATION## application.
+ *
+ * @package ##PROJECT##
+ * @subpackage form
+ * @author ##AUTHOR##
+ * @version SVN: $Id$
+ */
+class ##APPLICATION####MODEL##Form extends ##MODEL##Form
+{
+ /**
+ * @see sfForm
+ */
+ public function configure()
+ {
+ parent::configure();
+ }
+}
Property changes on:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form/form.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Added:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form_filter/form.class.php
===================================================================
---
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form_filter/form.class.php
(rev 0)
+++
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form_filter/form.class.php
2010-02-22 16:53:57 UTC (rev 28187)
@@ -0,0 +1,20 @@
+<?php
+
+/**
+ * ##MODEL## form filter class for the ##APPLICATION## application.
+ *
+ * @package ##PROJECT##
+ * @subpackage filter
+ * @author ##AUTHOR##
+ * @version SVN: $Id$
+ */
+class ##APPLICATION####MODEL##FormFilter extends ##MODEL##FormFilter
+{
+ /**
+ * @see sfForm
+ */
+ public function configure()
+ {
+ parent::configure();
+ }
+}
Property changes on:
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/propel/skeleton/app_form_filter/form.class.php
___________________________________________________________________
Added: svn:keywords
+ Id
Added: svn:eol-style
+ native
Modified: plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl
===================================================================
--- plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl 2010-02-22
14:45:05 UTC (rev 28186)
+++ plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl 2010-02-22
16:53:57 UTC (rev 28187)
@@ -130,6 +130,7 @@
<notes>
* Fixed bug when generating a test stub for a class in a plugin with
no test directory
* Added `doctrine:build-app-forms` and `doctrine:build-app-filters`
tasks
+ * Added `propel:build-app-forms` and `propel: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.