[TYPO3-ect] Best way to access request parameters from model?

Joerg Schoppet joerg at schoppet.de
Tue Oct 2 09:53:12 CEST 2007


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Elmar Hinz wrote:
> B) Taking parameters from a given request object:
> =================================================
> 
> $uid = $this->parameters->get('uid');
> $title = $this->parameters->get('title');
> 
> In the controller you just need to do:
> 
> $model->parameters = $this->parameters; 
> 
> Or similar like lib/div currently does
> $model->controller = $this->controller; 
> 
> and in the model
> $pars = $this->controller->parameters;
> $uid = $pars['uid'];
> $title = $pars['title'];
> 
> Advantages: 
> 
>  * There is often no typing in the controller.
>  * There is few typing in the model.
>  * Unit testing can be done by defining a parameters mock object.
> 
> Disadvantages: 
> 
>  * In complex forms you sometimes have to alter the parameters object
>    several time. That works but somehow feels wrong.
>  * The model depends on a lib/div like parameters object. It can't be 
>    exported to a different environment directly. (It can be preparing 
>    a paramtersobject there, which is not that difficult.)

Hi,

I would prefer B (the first B ;-) ).
To have an own paramter-object gives the programmer more freedom to
define all necessary validation and it represents the oo-way of
encapsulation.
The other thing is, that in the beta-branch it is planned to have a
global registry-object also for the parameters, so access will be
extremly simple from all parts of the extension.


Joerg
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFHAfjoq5Me6rRDqPURAgNFAJ9DpircS7IgsyoOiZWjdhZK6W+vtACgvHlc
/ZOc0zNkNj2WSvOI9x42wV8=
=68P1
-----END PGP SIGNATURE-----


More information about the TYPO3-team-extension-coordination mailing list