2009年3月6日星期五

Re: [fw-mvc] how to pass params to a Zend_Form construction


I agree with Giorgio, breaking the interface is not good. Perhaps Zend_Form should change its interface then Matthew?

--- On Sat, 3/7/09, Giorgio Sironi <piccoloprincipeazzurro@gmail.com> wrote:
From: Giorgio Sironi <piccoloprincipeazzurro@gmail.com>
Subject: Re: [fw-mvc] how to pass params to a Zend_Form construction
To: "Sebastien Crocquesel" <cortex93@gmail.com>
Cc: tvhoang1980@yahoo.com, fw-mvc@lists.zend.com
Date: Saturday, March 7, 2009, 12:41 AM

2009/3/6 Sebastien Crocquesel <cortex93@gmail.com>
What I have done is simple. I just override the default constructor with mine. In it, i call the parent one.
public __construct($myparam, $options)
{
  parent:__construct($options);
  // do someting with $myparam (database request to fill a Zend_Form_Select element for example).
  // this is code that i would have put in the controller when building the form if do not refactor in a Zend_Form subclass
}

I also like the idea to inject by constructor, but I'm not sure if this will be a violation of LSP because the signature of __construct is different (but striclty compatible) than the parent one.

--
Giorgio Sironi
Piccolo Principe & Ossigeno Scripter
http://ossigeno.sourceforge.net

没有评论: