I have two class definitions, Person and Course.
On Course, I’ve added Advanced Many-To-Many Object Relation called persons for Person objects, with a multiselect metadata field called roles (as Person can be, simultaneously, a lecturer, examiner, tutor,…).
Now I need to get Course objects for a single Person filtered by a specified role (the metadata field). Something along the lines of:
Normally, I would do something like this (or just use the Reverse Many-To-Many Object Relation):
$listing = new Course\Listing(); $listing->setCondition('persons LIKE ?', '%,' . $id . ',%');
But I can’t do that, as I’ve got my role metadata field to worry about now. I can filter out the roles “manually” after getting the data from the database, but that’s really clunky and inefficient. I can’t use dependencies either.
It would seem like joining the object_metadata table when building the listing would be the most efficient solution. But I don’t even know if that’s possible.
So, in short, how can I filter objects in a listing by their metadata fields? I can’t find a word on this in the documentation, so any help is appreciated. Thanks!