Author: marijn
Date: 2010-01-12 00:27:42 +0100 (Tue, 12 Jan 2010)
New Revision: 26504

Modified:
   
plugins/sfPaymentPlugin/branches/1.2-marijn/lib/action/sfPaymentActionAbstract.php
Log:
[sfPaymentPlugin] Added `sfPaymentActionAbstract#processForm()` method for 
handling boiler plate form processing.

Modified: 
plugins/sfPaymentPlugin/branches/1.2-marijn/lib/action/sfPaymentActionAbstract.php
===================================================================
--- 
plugins/sfPaymentPlugin/branches/1.2-marijn/lib/action/sfPaymentActionAbstract.php
  2010-01-11 23:23:50 UTC (rev 26503)
+++ 
plugins/sfPaymentPlugin/branches/1.2-marijn/lib/action/sfPaymentActionAbstract.php
  2010-01-11 23:27:42 UTC (rev 26504)
@@ -10,4 +10,46 @@
    */
   abstract class sfPaymentActionAbstract extends sfAction
   {
+
+    /**
+     * Process a form object.
+     *
+     * @param   sfPaymentFormAbstract $arg_form     The form to process.
+     * @param   sfWebRequest          $arg_request  The request object.
+     * @param   String                $arg_route    The route to which the 
form data should be submitted.
+     * @param   String                $arg_method   The form submit method.
+     *                                
+     * @return  String                              The view type to render.
+     */
+    protected function _processForm (sfPaymentFormAbstract $arg_form, 
sfWebRequest $arg_request, $arg_route, $arg_method = 'post')
+    {
+      $name = $arg_form->getName();
+
+      if ($arg_request->isMethod($arg_method) && 
$arg_request->hasParameter($name))
+      {
+        $arg_form->bind($arg_request->getParameter($name), 
$arg_form->isMultipart() ? $arg_request->getFiles($name) : NULL);
+
+        if ($arg_form->isValid())
+        {
+          $this->redirect(array('sf_route'   => $arg_route
+                               ,'sf_subject' => 
$this->_doProcessForm($arg_form)
+                               ));
+        }
+      }
+
+      return sfView::INPUT;
+    }
+
+    /**
+     * Process a form object when it is valid.
+     *
+     * @param   sfPaymentFormAbstract $arg_form     The form to process.
+     *
+     * @return  mixed
+     */
+    protected function _doProcessForm (sfPaymentFormAbstract $arg_form)
+    {
+      return $arg_form->process();
+    }
+
   }
\ No newline at end of file

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