You are here

function facets_update_8002 in Facets 8

Remove 'other_facet' plugin for older versions of facets.

File

./facets.install, line 88
Update hooks for the facets module.

Code

function facets_update_8002() {
  $database = \Drupal::database();
  $query = $database
    ->query("SELECT * FROM {config} WHERE data LIKE '%other_facet%'");
  $results = $query
    ->fetchAll();
  foreach ($results as $result) {
    $data = unserialize($result->data);
    if (isset($data['visibility']['other_facet'])) {
      unset($data['visibility']['other_facet']);
    }
    $database
      ->update('config')
      ->fields([
      'data' => serialize($data),
    ])
      ->condition('name', $result->name)
      ->execute();
  }
}