[TYPO3-mvc] extending news

Claus Due claus at wildside.dk
Tue Nov 15 18:30:09 CET 2011


PHP 5.4 will introduce Traits which can be used to fill exactly this requirement[1]

Traits behave much like Mixins in FLOW3. When this becomes possible it should be possible to adapt Extbase to define all DomainObjects as Traits, then add a default DomainObject class which implements the Trait(s) defined in the native extension.

Extensions can then use the Traits defined by other extensions, thus collecting them in a new DomainObject class which inherits all properties of the parents. Each individual DomainObject class from parent extensions would still be completely usable without any conflicts.

However, this can only work with DomainObjects actually using Traits (no Trait-based subclassing of "old" Extbase extensions).

Still it is the optimal solution, really. If I am not mistaken it would even be fully compatible with the existing Extbase methodology without any need for hacking and still allow full class reflection (and code completion if your IDE supports it). Looking very much forward to this PHP feature as it solves a huge interitance headache when you want to go full-out OOP. It would surely be superior to any solution based on magic methods...

The question then becomes:

Do we want/need/have to "preinvent" the wheel in Extbase when we know that a native PHP solution is coming fairly soon? My vote is a conservative "thanks but no thanks, wait for the good stuff and don't waste more effort on this"...


Cheers,
Claus

[1] http://php.net/manual/en/language.oop5.traits.php


On Nov 15, 2011, at 5:18 PM, Georg Ringer wrote:

> Am 15.11.2011 17:10, schrieb Bastian Waidelich:
>> In Extbase we won't have that feature. But if you only need the fields
>> in the Backend & Templates there are possible work-arounds. See [1] for
>> some infos and ideas we collected at the last DevDays.
>> 
>> [1]
>> http://forge.typo3.org/projects/typo3v4-mvc/wiki/Implementation_of_mixinsextendable_domain_models
> 
> IMO using the DI is not an option at all as it allows 1 override per extension and you can't use 2 extensions from TER without modifying those. (as written in the wiki already).
> 
> so there is really a need for a better built in solution! Just thinking "loud": what about adding new properties via TS
> 
> tx_news_domain_model_news.addProperties {
> 	fobar {
> 		var = string
> 		validate = Tx_Fobar_Validation_FoValidation
> 	}
> 
> }
> 
> ?
> 
> georg
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list