Ejemplo n.º 1
0
 /**
  * Tests for flattenFacetHierarchy
  */
 public function testFlattenFacetHierarchy()
 {
     $facetList = $this->helper->flattenFacetHierarchy($this->helper->buildFacetArray('format', $this->facetList));
     $this->assertEquals($facetList[0]['value'], '0/Book/');
     $this->assertEquals($facetList[1]['value'], '1/Book/BookPart/');
     $this->assertEquals($facetList[2]['value'], '1/Book/Section/');
     $this->assertEquals($facetList[3]['value'], '0/AV/');
     $this->assertEquals($facetList[4]['value'], '0/Audio/');
     $this->assertEquals($facetList[5]['value'], '1/Audio/Spoken/');
     $this->assertEquals($facetList[6]['value'], '1/Audio/Music/');
 }
Ejemplo n.º 2
0
 /**
  * Get facet information from the search results.
  *
  * @return array
  * @throws \Exception
  */
 public function getFacetSet()
 {
     $facetSet = $this->results->getFacetList($this->mainFacets);
     foreach ($this->hierarchicalFacets as $hierarchicalFacet) {
         if (isset($facetSet[$hierarchicalFacet])) {
             if (!$this->hierarchicalFacetHelper) {
                 throw new \Exception(get_class($this) . ': hierarchical facet helper unavailable');
             }
             $facetArray = $this->hierarchicalFacetHelper->buildFacetArray($hierarchicalFacet, $facetSet[$hierarchicalFacet]['list']);
             $facetSet[$hierarchicalFacet]['list'] = $this->hierarchicalFacetHelper->flattenFacetHierarchy($facetArray);
         }
     }
     return $facetSet;
 }