/** * Return the category totals for the search results. * * @param Hit[] * * @return array */ private function getCategoryTotals($hits) { $categoryNames = $this->searchManager->getCategoryNames(); $categoryCount = array_combine($categoryNames, array_fill(0, count($categoryNames), 0)); foreach ($hits as $hit) { $category = $hit->getDocument()->getCategory(); ++$categoryCount[$category]; } return $categoryCount; }