function facets_summary_update_8001 in Facets 8
Convert summaries on Search Api facet sources to use the display plugin.
File
- modules/
facets_summary/ facets_summary.install, line 13 - Update hooks for the facets summary module.
Code
function facets_summary_update_8001() {
/** @var \Drupal\facets_summary\FacetsSummaryInterface[] $entities */
$entities = FacetsSummary::loadMultiple();
foreach ($entities as $entity) {
$facetSourceId = $entity
->getFacetSourceId();
$old_ids = [
'views_page',
'views_block',
'views_rest',
];
foreach ($old_ids as $id) {
if (strpos($facetSourceId, $id) !== FALSE) {
$new_id = str_replace($id . ':', 'search_api:' . $id . '__', $facetSourceId);
$entity
->setFacetSourceId($new_id);
$entity
->save();
}
}
}
}