/** * Returns all FacetGroups, which matches the current facet group set * for example: * [['color'] => 'rot'] => * * @param FacetGroupSet $selectedFacetGroupSet * * @return FacetGroup[] */ public function getExcludedFacetGroups(FacetGroupSet $selectedFacetGroupSet) { /** @var FacetGroup[] $allGroups */ $allGroups = []; $selectedGroupIds = $selectedFacetGroupSet->getGroupIds(); foreach ($this->getVariants() as $variant) { $facetGroupSet = $variant->getFacetGroupSet(); if (!$facetGroupSet->contains($selectedFacetGroupSet)) { continue; } $ids = $facetGroupSet->getGroupIds(); foreach ($ids as $groupId) { if (in_array($groupId, $selectedGroupIds)) { continue; } $group = $facetGroupSet->getGroup($groupId); if ($group === null) { throw new RuntimeException('group for id ' . $groupId . ' not found'); } $facets = $group->getFacets(); if (empty($facets)) { continue; } if (!isset($allGroups[$groupId])) { $allGroups[$groupId] = new FacetGroup($group->getId(), $group->getName()); } $allGroups[$groupId]->addFacets($facets); } } return array_values($allGroups); }