diff --git a/facets.module b/facets.module index d174774..5c322cf 100644 --- a/facets.module +++ b/facets.module @@ -88,7 +88,7 @@ function facets_entity_presave(EntityInterface $entity) { // Check if the current display is also a facet source plugin and that // is removed from the view. We use the double underscore here to make // sure that we use core convention of "plugin:derived_plugin". - $facets_source_plugin_id = 'views_page:' . $entity->id() . '__' . $display['id']; + $facets_source_plugin_id = 'search_api:' . $entity->id() . '__' . $display['id']; if (array_key_exists($facets_source_plugin_id, $definitions) && !array_key_exists($k, $entity->get('display'))) { $entity_id = str_replace(':', '__', $facets_source_plugin_id); $source_entity = FacetSource::load($entity_id); @@ -150,7 +150,7 @@ function facets_entity_predelete(EntityInterface $entity) { } foreach ($definitions as $plugin_id => $definition) { - if (strpos($plugin_id, 'views_page:' . $entity->id() . '__') !== FALSE) { + if (strpos($plugin_id, 'search_api:' . $entity->id() . '__') !== FALSE) { try { $facetManager = \Drupal::getContainer()->get('facets.manager'); } catch (ServiceNotFoundException $e) { diff --git a/modules/rest_facets/src/Plugin/views/style/FacetsSerializer.php b/modules/rest_facets/src/Plugin/views/style/FacetsSerializer.php index 5c4a1d3..759fb16 100644 --- a/modules/rest_facets/src/Plugin/views/style/FacetsSerializer.php +++ b/modules/rest_facets/src/Plugin/views/style/FacetsSerializer.php @@ -80,7 +80,7 @@ class FacetsSerializer extends Serializer { } // Processing facets. - $facetsource_id = "views_page:{$this->view->id()}__{$this->view->getDisplay()->display['id']}"; + $facetsource_id = "search_api:{$this->view->id()}__{$this->view->getDisplay()->display['id']}"; $facets = $this->facetsManager->getFacetsByFacetSourceId($facetsource_id); $this->facetsManager->updateResults($facetsource_id); diff --git a/src/FacetManager/DefaultFacetManager.php b/src/FacetManager/DefaultFacetManager.php index c59d19a..253656c 100644 --- a/src/FacetManager/DefaultFacetManager.php +++ b/src/FacetManager/DefaultFacetManager.php @@ -138,6 +138,10 @@ class DefaultFacetManager { * The facet source ID to process. */ public function alterQuery(&$query, $facetsource_id) { + if ($this->getFacetsByFacetSourceId($facetsource_id) === []) { + return; + } + /** @var \Drupal\facets\FacetInterface[] $facets */ foreach ($this->getFacetsByFacetSourceId($facetsource_id) as $facet) { /** @var \Drupal\facets\QueryType\QueryTypeInterface $query_type_plugin */ diff --git a/tests/src/FunctionalJavascript/WidgetJSTest.php b/tests/src/FunctionalJavascript/WidgetJSTest.php index e085958..b63abed 100644 --- a/tests/src/FunctionalJavascript/WidgetJSTest.php +++ b/tests/src/FunctionalJavascript/WidgetJSTest.php @@ -52,10 +52,10 @@ class WidgetJSTest extends JavascriptTestBase { // Select one of the options from the facet source dropdown and wait for the // result to show. - $page->selectFieldOption('edit-facet-source-id', 'views_page:search_api_test_view__page_1'); + $page->selectFieldOption('edit-facet-source-id', 'search_api:search_api_test_view__page_1'); $this->getSession()->wait(6000, "jQuery('.facet-source-field-wrapper').length > 0"); - $page->selectFieldOption('facet_source_configs[views_page:search_api_test_view__page_1][field_identifier]', 'type'); + $page->selectFieldOption('facet_source_configs[search_api:search_api_test_view__page_1][field_identifier]', 'type'); // Check that after choosing the field, the name is already filled in. $field_value = $this->getSession()->getPage()->findField('edit-name')->getValue(); @@ -74,7 +74,7 @@ class WidgetJSTest extends JavascriptTestBase { 'id' => $id, 'name' => strtoupper($id), 'url_alias' => $id, - 'facet_source_id' => 'views_page:search_api_test_view__page_1', + 'facet_source_id' => 'search_api:search_api_test_view__page_1', 'field_identifier' => 'type', 'empty_behavior' => ['behavior' => 'none'], 'widget' => [