I’m working on a module that organizes user, resources and sites into related teams. I’m trying to modify the search api so that the results returned are filtered against the user’s current default team, or another of their teams they select in the advanced search. Right now I’m trying to accomplish this by using a join statement
$qb->innerJoin(
'Teams\Entity\TeamResource',
'tr',
Expr\Join::WITH,
$entityClass . '.id = tr.resource')
->where('tr.team = :team_id')
->setParameter('team_id', $team_id);
The TeamResources table contains columns with Omeka resource ids and team ids. The $team_id variable is returned by the advanced search form. I’m using the api.search.query event to inject this join statement.
The join seems to work when displaying all of the items/item sets/media/resource templates, but fails when using the advanced search to filter by value, class or template (filtering items by item set works). I get the error:
**Doctrine\ORM\Query\QueryException**
Too many parameters: the query defines 1 parameters and you bound 2
I’ve only tried this with the item advanced search so far. The error message always says that the query defines 1 + the number of item sets selected in the advanced search, and that I bound that number + the number of value, class and template parameters I selected in the advanced search. So, it seems like my join statement is interfering with building the property query, but still allowing the parameters for the property query to be bound.
I’m having a hard time debugging this. Is there somewhere I should look to get a better understanding of how the advanced search queries are built? Is there a more appropriate way to add a filter criteria to the search api?