You are here

facets_summary.install in Facets 8

Update hooks for the facets summary module.

File

modules/facets_summary/facets_summary.install
View source
<?php

/**
 * @file
 * Update hooks for the facets summary module.
 */
use Drupal\facets_summary\Entity\FacetsSummary;

/**
 * Convert summaries on Search Api facet sources to use the display plugin.
 */
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();
      }
    }
  }
}

Functions

Namesort descending Description
facets_summary_update_8001 Convert summaries on Search Api facet sources to use the display plugin.