8.4.2 How to filter with Doctrine and 2 independent fields

Permalink
I have a table of groups, a table of categories and a table of items with selected groups and categories.

To get a list of items with certain categories:
$list = $em->getRepository('RealEstate\Property\Property')->findBy(array('category' => $category_id));

To get a list of items with certain groups is the same.

I have a page with two types of menus: tabs with groups and links of categories.

When I press a tab with a group, I get a list of items filtered by that group. When I press a link with a category, I get a list of items filtered by that category.

The groups and categories are created by a user, so their names are unknown beforehand. For example the user entered groups 'Buy' and 'Sell', and categories 'A', 'B', 'C'

Now, I need the following functionality: if I go to a group 'Buy', then click on category 'A' - it should filter all items for 'A' and 'Buy' and to stay on the same tab showing filtered content.

I want to avoid copying the same code for each tab.

How can I select, I mean how can I pass, both the group and category at the same time to the controller for filtering if I only press on either of them?

linuxoid