Refactor-Step One

December 31, 2006 on 2:14 am | In Zend Framework |

By now, my  first  step of refactor for addAction(), editAction() etc. has been finished. They are all related FORM operation. First of all, I created a form controller which named FormController. Of course, the file name is FormController.php and the class name is FormController().

It looks like

Code (php)
  1.  
  2. class FormController extends Zend_Controller_Action
  3.  
  4. {
  5.    function init()
  6.    {
  7.     Zend::loadClass(‘Bookmark’);
  8.     Zend::loadClass(‘User’);
  9.    }
  10.    public function insertAction()
  11.    {
  12.  
  13.           $arg1  = $this->_request->getParam(‘arg1_name’, 0);
  14.           $args  = $this->_request->getParams();
  15.           …
  16.    }
  17. }
  18.  

in IndexController.php, the code would be

Code (php)
  1. function addAction()
  2. {              
  3.    $data = array
  4.    (   
  5.         ‘arg1_name’   => ‘arg1′,
  6.         ‘arg2_name’   => ‘arg2′,
  7.         ‘arg3_name’   => ‘arg3′
  8.    );
  9.        
  10.    $this->_forward(‘form’,‘insert’,$data);
  11. }

No Comments yet »

RSS feed for comments on this post. TrackBack URI

Leave a comment

XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Since May 6,2007 We have Visitors
dog ramps

Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds. Valid XHTML and CSS. ^Top^