[TYPO3-ect] Generated constructors in models/views (of Kickstarter MVC)
Elmar Hinz
elmar07 at googlemail.com
Mon Jul 30 11:12:48 CEST 2007
> Now the question:
> Is it better to remove the constructor-method, so that the parent
> constructor is called, or should I extend the method with the two optional
> parameters like in lib_object?
> Like this:
> function tx_extKey_model_xyz($parameter1 = null, $parameter2 = null) {
> parent::tx_lib_object($parameter1, $parameter2);
> }
>
> Or are there any different possibilities to pass data directly?
Hi Tim,
in doubt take bananas as orientation. kickstarter__mvc is still alpha.
Sometimes it is useful to overwrite the constructor. In the majority of
cases you don't need to do that.
Often the model takes data directly from the parameters object. Then this is
enough.
$modelClassName = tx_div::makeInstanceClassName('tx_extKey_model_xyz');
$model = new $modelClassName($this);
Sometimes you validate before, and you want to take data from the validator
object:
$modelClassName = tx_div::makeInstanceClassName('tx_extKey_model_xyz');
$model = new $modelClassName($this, $validator);
There many ways that work. I don't suggest a way to do it "best". It depends
on what you want to do and what your model exactly does and need.
Regards
Elmar
More information about the TYPO3-team-extension-coordination
mailing list