/** * Updates the facets with elements that have been added since * `installFacets` was called. */ public function updateFacetMappings() { $facetSet = array(); foreach ($this->findAll() as $facet) { $facetSet[$facet->element_id] = $facet; } $elementTable = $this->_db->getTable('Element'); $elementSet = array(); foreach ($elementTable->findAll() as $element) { if (!array_key_exists($element->id, $facetSet)) { $facet = new SolrSearchField($element); $facet->save(); } else { $elementSet[$element->id] = TRUE; } } foreach ($facetSet as $facetId => $facet) { if (!array_key_exists($facetId, $elementSet)) { $facet->delete(); } } }