Author: Kris.Wallsmith
Date: 2010-02-20 16:57:55 +0100 (Sat, 20 Feb 2010)
New Revision: 28152

Added:
   plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/
   
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/lib/task/doctrine/skeleton/
   plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form/
   
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form/form.class.php
Modified:
   plugins/sfTaskExtraPlugin/branches/1.3/README
   plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl
Log:
[sfTaskExtraPlugin] added doctrine:build-app-forms task

Modified: plugins/sfTaskExtraPlugin/branches/1.3/README
===================================================================
--- plugins/sfTaskExtraPlugin/branches/1.3/README       2010-02-20 14:41:56 UTC 
(rev 28151)
+++ plugins/sfTaskExtraPlugin/branches/1.3/README       2010-02-20 15:57:55 UTC 
(rev 28152)
@@ -1,12 +1,13 @@
 This plugin adds the following tasks to the symfony CLI:
 
-  * `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-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:
 

Added: 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
===================================================================
--- 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
                              (rev 0)
+++ 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
      2010-02-20 15:57:55 UTC (rev 28152)
@@ -0,0 +1,79 @@
+<?php
+
+require_once dirname(__FILE__).'/sfTaskExtraDoctrineBaseTask.class.php';
+
+/**
+ * Builds form classes in the application lib directory.
+ * 
+ * @package    sfTaskExtraPlugin
+ * @subpackage task
+ * @author     Kris Wallsmith <[email protected]>
+ * @version    SVN: $Id$
+ */
+class sfDoctrineBuildAppFormsTask 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-forms';
+
+    $this->briefDescription = 'Builds form 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'))
+    {
+      $skeletonDir = 
sfConfig::get('sf_data_dir').'/skeleton/doctrine_app_form';
+    }
+    else
+    {
+      $skeletonDir = dirname(__FILE__).'/skeleton/app_form';
+    }
+
+    // target directory
+    if (!file_exists($file = sfConfig::get('sf_app_lib_dir').'/form/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').'/form/doctrine/'.$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));
+      }
+    }
+  }
+}


Property changes on: 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfDoctrineBuildAppFormsTask.class.php
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
===================================================================
--- 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
                              (rev 0)
+++ 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
      2010-02-20 15:57:55 UTC (rev 28152)
@@ -0,0 +1,15 @@
+<?php
+
+require_once dirname(__FILE__).'/../sfTaskExtraBaseTask.class.php';
+
+/**
+ * Base Doctrine task.
+ *
+ * @package     sfTaskExtraPlugin
+ * @subpackage  task
+ * @author      Kris Wallsmith <[email protected]>
+ * @version     SVN: $Id$
+ */
+abstract class sfTaskExtraDoctrineBaseTask extends sfDoctrineBaseTask
+{
+}


Property changes on: 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/sfTaskExtraDoctrineBaseTask.class.php
___________________________________________________________________
Added: svn:keywords
   + Id
Added: svn:eol-style
   + native

Added: 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form/form.class.php
===================================================================
--- 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form/form.class.php
                           (rev 0)
+++ 
plugins/sfTaskExtraPlugin/branches/1.3/lib/task/doctrine/skeleton/app_form/form.class.php
   2010-02-20 15:57:55 UTC (rev 28152)
@@ -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/doctrine/skeleton/app_form/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-20 
14:41:56 UTC (rev 28151)
+++ plugins/sfTaskExtraPlugin/branches/1.3/package.xml.tmpl     2010-02-20 
15:57:55 UTC (rev 28152)
@@ -129,6 +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
       </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.

Reply via email to