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

Helmut Hummel helmut at typo3.org
Sat Jul 31 17:24:51 CEST 2010


Hi,

Disclaimer:

This proposal might also be interesting for FLOW3, but since I don't
know if it is already possible there with some AOP, ObjectManager or
similar magic, my proposal is mainly focused on V4 and extbase.


Problem:

In TYPO3 V4 it is easily possible for extensions to extend every
existing table with additional fields. But in extbase domain objects are
limited to a representation of a table with a certain fieldset. This of
course vastly improved with the single table inheritance feature, beeing
able to subclass a given domain object and adding the needed fields.
However it is impossible right now to have a domain object
representation containing all (extended) DB-fields as properties.
Thus the domain object needs to be adapted if an extension adds an
additional field to the database, which needs to be handled by the
domain object.

Solution:

At the T3DD10 I talked with Jochen Rau about the limitation of PHP not
providing mixed-ins for objects. Other programming languages allow
extending classes at runtime, so that an instance of the main class has
access to the properties and methods of the mixed-ins.

Example (pseudo code):

class Foo {
	protected $foo
	
	function getFoo() {
		return $this->foo;
	}
}

class Bar mixedin Foo {
	protected $bar

	function getBar() {
		return $this->bar;
	}
}

$object = $this->objectManager->get('Foo');
echo $object->getBar();


Implementation:

There must be a way to register a mixed-in for a given class. At
runtime, when a instance of this class is requested this registry is
checked and a new file is built containing a complete implementation of
the class containing all mixed-ins. This (new) class file would then be
required and instantiated.
For performance the generated file could be cached using the file cache
backend.


Before doing some work and provide a patch making this possible, I'd
like to hear if you think this is a good idea or not.


Regards Helmut


More information about the TYPO3-project-typo3v4mvc mailing list