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)
-
-
class FormController extends Zend_Controller_Action
-
-
{
-
function init()
-
{
-
Zend::loadClass(‘Bookmark’);
-
Zend::loadClass(‘User’);
-
}
-
public function insertAction()
-
{
-
-
$arg1 = $this->_request->getParam(‘arg1_name’, 0);
-
$args = $this->_request->getParams();
-
…
-
}
-
}
-
in IndexController.php, the code would be
Code (php)
-
function addAction()
-
{
-
$data = array
-
(
-
‘arg1_name’ => ‘arg1′,
-
‘arg2_name’ => ‘arg2′,
-
‘arg3_name’ => ‘arg3′
-
);
-
-
$this->_forward(‘form’,‘insert’,$data);
-
}
No Comments yet »
RSS feed for comments on this post. TrackBack URI
Leave a comment
Powered by WordPress with Pool theme design by Borja Fernandez.
Entries and comments feeds.
Valid XHTML and CSS. ^Top^