CoreCommunity ExtensionsIncubatorDistributionsTYPO3 4.5 ProjectsTYPO3 4.6 ProjectsTYPO3 4.7 ProjectsTYPO3 6.0 ProjectsTYPO3 6.1 ProjectsTYPO3 6.2 Projects (+)

Task #9682

Story #11938: As an extension developer I want to be able to use bidirectional relations

Getter methods for foreign key fields

Added by Martin Helmich over 2 years ago. Updated over 2 years ago.

Status:New Start date:2010-09-10
Priority:Should have Due date:
Assignee:- % Done:

0%

Category:-
Target version:-
Remaining hours
Votes: 0

Description

At the moment, for foreign key fields only a passthrough field is created in the TCA of the referenced object.

Occasionally however, it would be nice if such a relation could be traversed in both directions (if you have for example two domain objects "Group" and "User", then you might want to have a method Group::getUsers() but also a method User::getGroup()).

I have attached a rudimentary patch that replaces the default passthrough field that is generated for the referenced table with a select-Field and adds an appropriate getter method in the domain model object.

An alternative solution would be to have the user create two separate unidirectional relations, i.e. in the example above one 0..* relation from "Group" -> "User" and a 0..1 relation from "User" -> "Group". In this case however, the kickstarter creates two fields both named "group", one as a passthrough, and the other as an inline field...

getterForForeignKeys.diff (3.2 kB) Martin Helmich, 2010-09-10 15:58

getterForForeignKeys-2.diff - Updated patch. (4.2 kB) Martin Helmich, 2010-09-13 15:20

History

Updated by Martin Helmich over 2 years ago

Ouch. Apparently, I was not in my best state of mind when writing this issue; in my patch, I mixed up the different table names of the relations; an updated patch is attached... ;)

Updated by Rens Admiraal over 2 years ago

  • Tracker changed from Feature to Task
  • Parent task set to #11938

Also available in: Atom PDF