Author: fizyk
Date: 2010-04-07 23:00:08 +0200 (Wed, 07 Apr 2010)
New Revision: 29039

Modified:
   plugins/sfForkedDoctrineApplyPlugin/trunk/config/app.yml
   
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/action/sfApplyActionsLibrary.class.php
   plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyApplyForm.class.php
   
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyResetRequestForm.class.php
Log:
added possibility to override ApplyForms with their customised instances


Modified: plugins/sfForkedDoctrineApplyPlugin/trunk/config/app.yml
===================================================================
--- plugins/sfForkedDoctrineApplyPlugin/trunk/config/app.yml    2010-04-07 
20:07:15 UTC (rev 29038)
+++ plugins/sfForkedDoctrineApplyPlugin/trunk/config/app.yml    2010-04-07 
21:00:08 UTC (rev 29039)
@@ -2,3 +2,8 @@
 all:
   recaptcha:
     enabled: false
+  sfForkedApply:
+    applyForm: sfApplyApplyForm
+    resetForm: sfApplyResetForm
+    resetRequestForm: sfApplyResetRequestForm
+    settingsForm: sfApplySettingsForm

Modified: 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/action/sfApplyActionsLibrary.class.php
===================================================================
--- 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/action/sfApplyActionsLibrary.class.php
        2010-04-07 20:07:15 UTC (rev 29038)
+++ 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/action/sfApplyActionsLibrary.class.php
        2010-04-07 21:00:08 UTC (rev 29039)
@@ -11,7 +11,15 @@
     //When user is applying for new account
     public function executeApply(sfRequest $request)
     {
-        $this->form = $this->newForm('sfApplyApplyForm');
+        // we're getting default or customized applyForm for the task
+        if( !( ($this->form = $this->newForm( 
+                sfConfig::get( 'app_sfForkedApply_applyForm', 
'sfApplyApplyForm' ))
+                ) instanceof sfApplyApplyForm) )
+        {
+            // if the form isn't instance of sfApplyApplyForm, we don't accept 
it
+            throw new InvalidArgumentException(
+                    'The custom apply form should be instance of 
sfApplyApplyForm' );
+        }
 
         //Code below is used when user is sending his application!
         if( $request->isMethod('post') )
@@ -66,7 +74,16 @@
         }
         else
         {
-            $this->form = $this->newForm('sfApplyResetRequestForm');
+            // we're getting default or customized resetRequestForm for the 
task
+            if( !( ($this->form = $this->newForm(
+                    sfConfig::get( 'app_sfForkedApply_resetRequestForm', 
'sfApplyResetRequestForm' ) )
+                    ) instanceof sfApplyResetRequestForm) )
+            {
+                // if the form isn't instance of sfApplySettingsForm, we don't 
accept it
+                throw new InvalidArgumentException( 
+                        'The custom resetRequest form should be instance of 
sfApplyResetRequestForm'
+                        );
+            }
             if ($request->isMethod('post'))
             {
                 //gathering form request in one array
@@ -152,7 +169,16 @@
         {
             $this->redirect( '@sf_guard_signin' );
         }
-        $this->form = $this->newForm('sfApplyResetForm');
+        // we're getting default or customized resetForm for the task
+        if( !( ($this->form = $this->newForm(
+                sfConfig::get( 'app_sfForkedApply_resetForm', 
'sfApplyResetForm' ))
+                ) instanceof sfApplyResetForm) )
+        {
+            // if the form isn't instance of sfApplyResetForm, we don't accept 
it
+            throw new InvalidArgumentException( 
+                    'The custom reset form should be instance of 
sfApplyResetForm'
+                    );
+        }
         if ($request->isMethod('post'))
         {
             $this->form->bind($request->getParameter('sfApplyReset'));
@@ -193,7 +219,19 @@
         // your own configure() method.
 
         $profile = $this->getUser()->getProfile();
-        $this->form = $this->newForm('sfApplySettingsForm', $profile);
+        // we're getting default or customized settingsForm for the task
+        if( !( ($this->form = $this->newForm(
+                sfConfig::get( 'app_sfForkedApply_settingsForm', 
'sfApplySettingsForm' ), $profile)
+                ) instanceof sfApplySettingsForm) )
+        {
+            // if the form isn't instance of sfApplySettingsForm, we don't 
accept it
+            throw new InvalidArgumentException( sfContext::getInstance()->
+                    getI18N()->
+                    __( 'The custom %action% form should be instance of 
%form%',
+                            array( '%action%' => 'settings',
+                                '%form%' => 'sfApplySettingsForm' ), 
'sfForkedApply' )
+                    );
+        }
         if ($request->isMethod('post'))
         {
             $this->form->bind($request->getParameter('sfApplySettings'));

Modified: 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyApplyForm.class.php
===================================================================
--- 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyApplyForm.class.php   
    2010-04-07 20:07:15 UTC (rev 29038)
+++ 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyApplyForm.class.php   
    2010-04-07 21:00:08 UTC (rev 29039)
@@ -1,6 +1,9 @@
 <?php
 
-//TODO! Add captcha!
+/**
+ * Form for account apply, allows to create profile (sfGuardUserProfile) and 
account (sfGuardUser)
+ * @author fizyk
+ */
 class sfApplyApplyForm extends sfGuardUserProfileForm
 {
     private $validate = null;

Modified: 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyResetRequestForm.class.php
===================================================================
--- 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyResetRequestForm.class.php
        2010-04-07 20:07:15 UTC (rev 29038)
+++ 
plugins/sfForkedDoctrineApplyPlugin/trunk/lib/form/sfApplyResetRequestForm.class.php
        2010-04-07 21:00:08 UTC (rev 29039)
@@ -1,6 +1,5 @@
 <?php
 
-//TODO! Add captcha!
 class sfApplyResetRequestForm extends sfForm
 {
     public function configure()

-- 
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