[TYPO3-mvc] Annotaion based relation-type-detection

Jochen Rau jochen.rau at typoplanet.de
Fri Apr 16 10:02:30 CEST 2010


Hi Felix.

Thanks for your effort to implement this proposal.

On 16.04.10 01:23, Felix Oertel wrote:
> we all know, we had ... erm, let's say: "issues" with IRRE. ;-) The hole
> system is not meant to be a good way to detect a databse-relation-type.

True. This is mainly caused by two issues with IRRE:
- IRRE doesn't allow to to have a record selector with pure 1:n relations
- The default for "maxitems" in IRRE is 100000 and not 1 like it is 
documented (I already reported the bug and it is solved by changing the 
documentation)

> As we use annotations anyway, we should act consistently and detect the
> database's relation-type by using an annotation.
>
> This patch will introduce three new annotations:
> @OneToOne
> @OneToMany and
> @ManyToMany
>
> Just add them to your model's property like:
>
> /**
> * @var Tx_YourExt_Domain_Model_Foo $foo
> * @oneToOne
> */
> protected $foo;
>
> and extbase will do the rest. Don't care for foreign_field, MM,
> foreign_selector or some other magic field in TCA anymore.

You are right. Extbase and FLOW3 makes heavy use of annotations. They 
are all related to the semantics of property and and to the domain (ok 
@lazy does not really belong to the domain -- hopefully ;-) ). From the 
perspective of the property it is important to distinguish between 
single value and multivalue. But it does not matter if the objects are 
referenced by another porperty, too (m:n).

We can perfectly distinguish between single and multivalue:
@var Tx_YourExt_Domain_Model_Foo
@var Tx_Extbase_Persistence_ObjectStorage<Tx_YourExt_Domain_Model_Foo>

In the persistence layer we also have to know about how the relation 
information is persisted (CSV, foreign key, intermediate table). That's 
were m:n relations come in place. But this can (and has to be) solved in 
this layer.

The solution will break all existing extensions and it is out of sync 
with FLOW3. I won't do that without a good reason.

> PS: As discussed with Jochen we want to replace (!) TCA detection with
> annotation based detection, so TCA-config is not used at all and you
> HAVE TO use the annotations.

Well, maybe we misunderstood each other. I don't want to replace all the 
TCA detection. My aim is to detect the relation type (single value / 
multivalue) by using the existing @var annotation, so we do not have to 
rely on the "maxitems" thing anymore. Then we can take "foreign_table", 
"foreign_key", and "MM" to detect how the relation information is stored 
technically. Support for intermediate table as "foreign_table" will be 
dropped in Extbase in the future (same in IRRE where it is more a matter 
of documentation).

I hope my reply does not discourage you ;-) I am always open-minded 
about new ideas and like to discuss them in this mailing list. So keep 
up the good work!

Regards
Jochen


More information about the TYPO3-project-typo3v4mvc mailing list