Skip to content

Commit

Permalink
Check facets configuration imported when index enabled.
Browse files Browse the repository at this point in the history
The facets configuration won't be enabled when the index has the
field added if the index is disabled at the time. Check when
the index is updated, if it is enabled and has the field, create
the facet (the create method also checks that it doesn't already
exist).
  • Loading branch information
ekes committed Mar 11, 2024
1 parent 2dd0118 commit 4b39dd6
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions localgov_directories.module
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,18 @@ function localgov_directories_field_config_delete(FieldConfigInterface $field) {
}
}

/**
* Implements hook_ENTITY_TYPE_update().
*/
function localgov_directories_search_api_index_update(IndexInterface $index) {
if ($index->status()
&& $index->getField(Directory::FACET_INDEXING_FIELD)
) {
\Drupal::classResolver(ConfigurationHelper::class)
->createFacet(Directory::FACET_CONFIG_ENTITY_ID, Directory::FACET_CONFIG_FILE);
}
}

/**
* Implements theme preprocess_facets_item_list().
*
Expand Down

0 comments on commit 4b39dd6

Please sign in to comment.