예제 #1
0
 /**
  * @param Facet\PropertyFacet $facet
  * @param Struct\Property\Set[] $sets
  * @param int[] $actives
  * @return FacetResultGroup
  */
 private function createCollectionResult(Facet\PropertyFacet $facet, array $sets, $actives)
 {
     $results = [];
     foreach ($sets as $set) {
         foreach ($set->getGroups() as $group) {
             $items = [];
             $useMedia = false;
             $isActive = false;
             foreach ($group->getOptions() as $option) {
                 $listItem = new MediaListItem($option->getId(), $option->getName(), in_array($option->getId(), $actives), $option->getMedia());
                 $isActive = $isActive || $listItem->isActive();
                 $useMedia = $useMedia || $listItem->getMedia() !== null;
                 $items[] = $listItem;
             }
             if ($useMedia) {
                 $results[] = new MediaListFacetResult($facet->getName(), $isActive, $group->getName(), $items, $this->fieldName);
             } else {
                 $results[] = new ValueListFacetResult($facet->getName(), $isActive, $group->getName(), $items, $this->fieldName);
             }
         }
     }
     return new FacetResultGroup($results, null, $facet->getName());
 }
예제 #2
0
 /**
  * @param Group[] $groups
  * @param int[] $actives
  * @return FacetResultGroup
  */
 private function createCollectionResult(array $groups, $actives)
 {
     $results = [];
     if (!($fieldName = $this->queryAliasMapper->getShortAlias('sFilterProperties'))) {
         $fieldName = 'sFilterProperties';
     }
     foreach ($groups as $group) {
         $items = [];
         $useMedia = false;
         $isActive = false;
         foreach ($group->getOptions() as $option) {
             $listItem = new MediaListItem($option->getId(), $option->getName(), in_array($option->getId(), $actives), $option->getMedia());
             $isActive = $isActive || $listItem->isActive();
             $useMedia = $useMedia || $listItem->getMedia() !== null;
             $items[] = $listItem;
         }
         if ($useMedia) {
             $results[] = new MediaListFacetResult('property', $isActive, $group->getName(), $items, $fieldName);
         } else {
             $results[] = new ValueListFacetResult('property', $isActive, $group->getName(), $items, $fieldName);
         }
     }
     return new FacetResultGroup($results, null, 'property');
 }