/** * Returns the stored list of facets for the last search * * @param array $filter Array of field => on-screen description listing * all of the desired facet fields; set to null to get all configured values. * * @return array Facets data arrays */ public function getFacetList($filter = null) { // Make sure we have processed the search before proceeding: if (is_null($this->user)) { $this->performAndProcessSearch(); } // If there is no filter, we'll use all facets as the filter: if (is_null($filter)) { $filter = $this->getParams()->getFacetConfig(); } // Start building the facet list: $retVal = []; // Loop through every requested field: $validFields = array_keys($filter); foreach ($validFields as $field) { if (!isset($this->facets[$field])) { $this->facets[$field] = ['label' => $this->getParams()->getFacetLabel($field), 'list' => []]; switch ($field) { case 'tags': if ($this->list) { $tags = $this->list->getTags(); } else { $tags = $this->user ? $this->user->getTags() : []; } foreach ($tags as $tag) { $this->facets[$field]['list'][] = ['value' => $tag->tag, 'displayText' => $tag->tag, 'count' => $tag->cnt, 'isApplied' => $this->getParams()->hasFilter("{$field}:" . $tag->tag)]; } break; } } if (isset($this->facets[$field])) { $retVal[$field] = $this->facets[$field]; } } return $retVal; }