[TYPO3-english] Extbase/Fluid extension: m:n relation constraint in repository (T3 6.2.4)

Hagen Gebauer gebauer at mpi-cbg.de
Tue Mar 3 10:19:23 CET 2015


Hi everybody,

I am stuck with a small calendar extension I am currently writing. I have a m:n relation between two of the models. The output in the frontend works totally fine. But I need to add a constraint to the repository asking for a UID of one of the models to get all associated objects of the other. I have not found a way yet to add this constraint. The important domain models for my question are:

Calendars -- m:n -- Events

Meaning: I want to be able to add events to various calendars. Then select a calendar in the backend and display the respective events in the frontend.

I tried what I saw in other extensions and also found as working ways in some forums (1st test in the below method) and also tried some variations. But obviously I am missing something. Here's what I checked within the repository method. I also added the TYPO3 error messages I received.

("calendars" is the model name)
("event_cal" is the property name of the relation within the events model)

/**
 * @param $calID
 */
public function eventsByCal($calID) {
$query = $this->createQuery();
$query = $query->matching(
//1st test: $query->contains('event_cal.uid', $calID), // Error: The ColumnMap for property "event_cal" is missing
//2nd test: $query->contains('calendars.uid', $calID), // Error: The relation information for property "calendars" is missing
//3rd test: $query->contains('event_cal', $calID), // Error: Unsupported or non-existing property name "event_cal" used in relation matching.
//4th test: $query->contains('calendars', $calID), // Error: Unsupported or non-existing property name "calendars" used in relation matching.
);
return $query->execute();
}

I also read something about the DataMapper but I am not sure this is what I need and I also did not find anything on how to use it.

Thanks for any help in advance!

Cheers,
Hagen.


More information about the TYPO3-english mailing list