[TYPO3-mvc] Proposal: mixed-ins for extbase

Franz Koch typo3.RemoveForMessage at elements-net.de
Mon Sep 6 11:11:28 CEST 2010


Hey Sebastian,

> with Helmut's ideas, it will be possible to access methods of the base
> class inside the mixins, so you can interact with values and/or methods
> in other mixins, i.e. call them or read out their values.
>
> So, while it is not possible to *override* methods from the start, it is
> possible to work around this problem: Imagine the following:
>
> // in abstract model "User"
> // $name with getters and setters
>
> // Now, I want to provide a mixin which extends "setName" with the
> saltation (Mr. or Mrs.), so I need an additional field:
>
> $saltation
> public function getNameWithSaltation() {
> 	return $this->saltation . $this->getName();
> }
>
> So, when creating a mixin, one usually also controls the Fluid Template
> where the mixed-in object is shown, and can thus use the modified
> accessors instead of the original ones, so instead of doing {user.name},
> one needs to do {user.nameWithSaltation}.

well, that's only working if no domain logic depends on the setters or 
getters. That's of course possible, but not that useful for more complex 
scenarios. Just imagine that you like to extend a shop and need to 
extend the features of the basket, like setting some additional 
attributes to a basket item as soon as it get's added to the basket.

How about my proposal with the possibility to register 
"override-methods" the same way as the mixins in Helmuts proposal? It 
would be just as easy to implement by adding a few more lines to the 
needed code for creating the mixins. I'd be willing to add that feature 
once the basic mixin stuff is up and running.

-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list