diff --git a/modules/acquia_cms_search/acquia_cms_search.info.yml b/modules/acquia_cms_search/acquia_cms_search.info.yml index 74ddb9f01..236651b4f 100644 --- a/modules/acquia_cms_search/acquia_cms_search.info.yml +++ b/modules/acquia_cms_search/acquia_cms_search.info.yml @@ -4,7 +4,6 @@ description: "Provides powerful search capabilities to the site" type: module core_version_requirement: ^10.1 || ^11 dependencies: - - acquia_cms_common:acquia_cms_common - collapsiblock:collapsiblock - facets:facets - facets_pretty_paths:facets_pretty_paths diff --git a/modules/acquia_cms_search/acquia_cms_search.install b/modules/acquia_cms_search/acquia_cms_search.install index 355a01258..563fa3352 100644 --- a/modules/acquia_cms_search/acquia_cms_search.install +++ b/modules/acquia_cms_search/acquia_cms_search.install @@ -24,21 +24,15 @@ function acquia_cms_search_install($is_syncing) { // Retroactively enable indexing for any content types that existed before // this module was installed. - $node_types = NodeType::loadMultiple(); + $node_types = \Drupal::entityTypeManager()->getStorage('node_type')->loadMultiple(); array_walk($node_types, 'acquia_cms_search_node_type_insert'); - $enabled_modules = \Drupal::service('module_handler')->getModuleList(); - $enabled_modules = array_keys($enabled_modules); - _acquia_cms_search_add_category_facet($enabled_modules); + $search_category = \Drupal::entityTypeManager()->getStorage('facets_facet')->loadByProperties(['id' => 'search_category']); + if (!$search_category) { + _acquia_cms_search_add_category_facet(); + } } } -/** - * Implements hook_module_preinstall(). - */ -function acquia_cms_search_module_preinstall($module) { - \Drupal::service('acquia_cms_common.utility')->setModulePreinstallTriggered($module); -} - /** * Added enforced dependency in site studio templates for Acquia CMS Search. * diff --git a/modules/acquia_cms_search/acquia_cms_search.module b/modules/acquia_cms_search/acquia_cms_search.module index 06f3a9de6..9ced8697f 100644 --- a/modules/acquia_cms_search/acquia_cms_search.module +++ b/modules/acquia_cms_search/acquia_cms_search.module @@ -65,6 +65,9 @@ function acquia_cms_search_views_plugins_cache_alter(&$definitions) { */ function acquia_cms_search_node_type_insert(NodeTypeInterface $node_type) { Drupal::classResolver(SearchFacade::class)->addNodeType($node_type); + if (!$node_type->isSyncing()) { + _acquia_cms_search_add_category_facet(); + } } /** @@ -76,12 +79,6 @@ function acquia_cms_search_field_config_insert(FieldConfigInterface $field_confi // Adding the third party settings in the node.body storage configuration to // index the body field for searching. - if ($field_storage->getType() === 'text_with_summary' && $field_storage->id() === 'node.body') { - $field_storage->setThirdPartySetting('acquia_cms_common', 'search_index', 'content') - ->setThirdPartySetting('acquia_cms_common', 'search_label', 'Body') - ->save(); - } - if ($field_storage->getType() === 'entity_reference' && $field_storage->getSetting('target_type') === 'taxonomy_term') { Drupal::classResolver(SearchFacade::class)->addTaxonomyField($field_storage); } @@ -180,26 +177,12 @@ function acquia_cms_search_form_acquia_cms_search_form_alter(array &$form) { $form['#submit'][] = AcquiaSearchFacade::class . '::submitSettingsForm'; } -/** - * Implements hook_modules_installed(). - */ -function acquia_cms_search_modules_installed(array $modules, $is_syncing) { - if (!$is_syncing) { - _acquia_cms_search_add_category_facet($modules); - } -} - /** * Adds search_category facet, if any acms search dependent module is installed. - * - * @param array $modules - * An array of installed modules. */ -function _acquia_cms_search_add_category_facet(array $modules) { - $acquiaCmsSearchModules = ["acquia_cms_person", "acquia_cms_place", - "acquia_cms_article", "acquia_cms_event", "acquia_cms_page", - ]; - if (array_intersect($acquiaCmsSearchModules, $modules)) { +function _acquia_cms_search_add_category_facet() { + $search_category = \Drupal::entityTypeManager()->getStorage('facets_facet')->loadByProperties(['id' => 'search_category']); + if (!$search_category) { \Drupal::classResolver(FacetFacade::class)->addFacet([ 'id' => 'search_category', 'name' => 'Category', diff --git a/modules/acquia_cms_search/composer.json b/modules/acquia_cms_search/composer.json index a83874e2e..5dcfaf4d5 100644 --- a/modules/acquia_cms_search/composer.json +++ b/modules/acquia_cms_search/composer.json @@ -4,8 +4,6 @@ "license": "GPL-2.0-or-later", "type": "drupal-module", "require": { - "cweagans/composer-patches": "^1.7", - "drupal/acquia_cms_common": "^1.9 || ^2.1 || ^3.1", "drupal/acquia_search": "^3.1", "drupal/collapsiblock": "^4.0", "drupal/facets": "^2.0", diff --git a/modules/acquia_cms_search/config/optional/block.block.clear_facet_filters.yml b/modules/acquia_cms_search/config/optional/block.block.clear_facet_filters.yml index 90b47eb82..87f3ab9fb 100644 --- a/modules/acquia_cms_search/config/optional/block.block.clear_facet_filters.yml +++ b/modules/acquia_cms_search/config/optional/block.block.clear_facet_filters.yml @@ -3,16 +3,10 @@ status: true dependencies: module: - acquia_cms_search - - cohesion - collapsiblock - theme: - - cohesion_theme -third_party_settings: - collapsiblock: - collapse_action: 0 id: clear_facet_filters -theme: cohesion_theme -region: dx8_hidden +theme: olivero +region: sidebar weight: 0 provider: null plugin: clear_facet_filters @@ -22,7 +16,7 @@ settings: label_display: '0' provider: acquia_cms_search visibility: - cohesion_master_template: - id: cohesion_master_template + request_path: + id: request_path negate: false - using_master_template: 0 + pages: "/articles\r\n/events\r\n/places\r\n/people" diff --git a/modules/acquia_cms_search/config/optional/block.block.exposed_form_search.yml b/modules/acquia_cms_search/config/optional/block.block.exposed_form_search.yml index 1694dd340..d7bc3b847 100644 --- a/modules/acquia_cms_search/config/optional/block.block.exposed_form_search.yml +++ b/modules/acquia_cms_search/config/optional/block.block.exposed_form_search.yml @@ -4,13 +4,10 @@ dependencies: config: - views.view.search module: - - cohesion - views - theme: - - cohesion_theme id: exposed_form_search -theme: cohesion_theme -region: dx8_hidden +theme: olivero +region: sidebar weight: 0 provider: null plugin: 'views_exposed_filter_block:search-search' @@ -21,7 +18,7 @@ settings: provider: views views_label: '' visibility: - cohesion_master_template: - id: cohesion_master_template + request_path: + id: request_path negate: false - using_master_template: 0 + pages: "/search" diff --git a/modules/acquia_cms_search/config/optional/block.block.search_category.yml b/modules/acquia_cms_search/config/optional/block.block.search_category.yml index 3cfd5a2cd..7d9d46b3e 100644 --- a/modules/acquia_cms_search/config/optional/block.block.search_category.yml +++ b/modules/acquia_cms_search/config/optional/block.block.search_category.yml @@ -4,17 +4,14 @@ dependencies: config: - facets.facet.search_category module: - - cohesion - collapsiblock - facets - theme: - - cohesion_theme third_party_settings: collapsiblock: collapse_action: 2 id: search_category -theme: cohesion_theme -region: dx8_hidden +theme: olivero +region: sidebar weight: 0 provider: null plugin: 'facet_block:search_category' @@ -25,7 +22,7 @@ settings: provider: facets block_id: search_category visibility: - cohesion_master_template: - id: cohesion_master_template + request_path: + id: request_path negate: false - using_master_template: 0 + pages: "/search" diff --git a/modules/acquia_cms_search/config/optional/block.block.search_content_type.yml b/modules/acquia_cms_search/config/optional/block.block.search_content_type.yml index 41370f512..b0a84d10f 100644 --- a/modules/acquia_cms_search/config/optional/block.block.search_content_type.yml +++ b/modules/acquia_cms_search/config/optional/block.block.search_content_type.yml @@ -4,17 +4,14 @@ dependencies: config: - facets.facet.search_content_type module: - - cohesion - collapsiblock - facets - theme: - - cohesion_theme third_party_settings: collapsiblock: collapse_action: 2 id: search_content_type -theme: cohesion_theme -region: dx8_hidden +theme: olivero +region: sidebar weight: 0 provider: null plugin: 'facet_block:search_content_type' @@ -25,7 +22,7 @@ settings: provider: facets block_id: search_content_type visibility: - cohesion_master_template: - id: cohesion_master_template + request_path: + id: request_path negate: false - using_master_template: 0 + pages: "/search" diff --git a/modules/acquia_cms_search/config/install/search_api.index.content.yml b/modules/acquia_cms_search/config/optional/search_api.index.content.yml similarity index 97% rename from modules/acquia_cms_search/config/install/search_api.index.content.yml rename to modules/acquia_cms_search/config/optional/search_api.index.content.yml index ab47530fd..5bff5dcdf 100644 --- a/modules/acquia_cms_search/config/install/search_api.index.content.yml +++ b/modules/acquia_cms_search/config/optional/search_api.index.content.yml @@ -9,9 +9,6 @@ dependencies: enforced: module: - acquia_cms_search -third_party_settings: - acquia_cms_common: - search_server: database id: content name: Content description: 'An index of all content in your site.' diff --git a/modules/acquia_cms_search/config/install/search_api_autocomplete.search.search.yml b/modules/acquia_cms_search/config/optional/search_api_autocomplete.search.search.yml similarity index 100% rename from modules/acquia_cms_search/config/install/search_api_autocomplete.search.search.yml rename to modules/acquia_cms_search/config/optional/search_api_autocomplete.search.search.yml diff --git a/modules/acquia_cms_search/config/optional/views.view.acquia_search.yml b/modules/acquia_cms_search/config/optional/views.view.acquia_search.yml index b892b7c9c..5f44dab07 100644 --- a/modules/acquia_cms_search/config/optional/views.view.acquia_search.yml +++ b/modules/acquia_cms_search/config/optional/views.view.acquia_search.yml @@ -6,10 +6,10 @@ dependencies: - search_api.index.acquia_search_index - system.menu.main module: + - acquia_search - search_api - text - user - - acquia_cms_development id: acquia_search label: 'Acquia Search Solr' module: views diff --git a/modules/acquia_cms_search/config/install/views.view.search.yml b/modules/acquia_cms_search/config/optional/views.view.search.yml similarity index 99% rename from modules/acquia_cms_search/config/install/views.view.search.yml rename to modules/acquia_cms_search/config/optional/views.view.search.yml index 438d9f737..b8654a8a1 100644 --- a/modules/acquia_cms_search/config/install/views.view.search.yml +++ b/modules/acquia_cms_search/config/optional/views.view.search.yml @@ -5,7 +5,6 @@ dependencies: - search_api.index.content - views.view.search_fallback module: - - acquia_cms_search - search_api - user id: search diff --git a/modules/acquia_cms_search/config/install/views.view.search_fallback.yml b/modules/acquia_cms_search/config/optional/views.view.search_fallback.yml similarity index 100% rename from modules/acquia_cms_search/config/install/views.view.search_fallback.yml rename to modules/acquia_cms_search/config/optional/views.view.search_fallback.yml diff --git a/modules/acquia_cms_search/src/Facade/SearchFacade.php b/modules/acquia_cms_search/src/Facade/SearchFacade.php index 6e37ab75f..1c6b068d4 100644 --- a/modules/acquia_cms_search/src/Facade/SearchFacade.php +++ b/modules/acquia_cms_search/src/Facade/SearchFacade.php @@ -131,7 +131,7 @@ public function addNodeType(NodeTypeInterface $node_type) { // Retroactively enable indexing for any fields that existed before this // module was installed. $fields = $this->fieldConfigStorage->loadMultiple(); - array_walk($fields, 'acquia_cms_search_field_config_insert'); + array_walk($fields, 'acquia_cms_search_field_config_insert'); // we have validated till here. // Update the view mode used for this node type in the Search view. /** @var \Drupal\views\ViewEntityInterface $view */ @@ -179,8 +179,7 @@ public function addTaxonomyField(FieldStorageConfigInterface $field_storage) { // Field storages don't normally have a human-readable label, so allow it to // provide one in its third-party settings. - $field_label = $field_storage->getThirdPartySetting('acquia_cms_common', 'search_label') ?: $field_storage->getLabel(); - + $field_label = $field_storage->getThirdPartySetting('acquia_cms_search', 'search_label') ?: $field_storage->getLabel(); $data_source_id = 'entity:' . $field_storage->getTargetEntityTypeId(); // This will throw an exception if the data source doesn't exist, so this // is really just a way to prevent the field from using an invalid data @@ -223,9 +222,7 @@ public function addFields(FieldStorageConfigInterface $field_storage) { if (empty($index)) { return; } - $field_name = $field_storage->getName(); - // Bail out if the field already exists on the index. if ($index->getField($field_name)) { return; @@ -234,7 +231,7 @@ public function addFields(FieldStorageConfigInterface $field_storage) { $field_type = $field_storage->getType(); // Field storages don't normally have a human-readable label, so allow it to // provide one in its third-party settings. - $field_label = $field_storage->getThirdPartySetting('acquia_cms_common', 'search_label') ?: $field_storage->getLabel(); + $field_label = $field_storage->getThirdPartySetting('acquia_cms_search', 'search_label') ?: $field_storage->getLabel(); $data_source_id = 'entity:' . $field_storage->getTargetEntityTypeId(); // This will throw an exception if the data source doesn't exist, so this @@ -286,7 +283,12 @@ private function loadIndexFromSettings(ThirdPartySettingsInterface $object) : ?I if ($this->configInstaller->isSyncing()) { return NULL; } - $index = $object->getThirdPartySetting('acquia_cms_common', 'search_index'); + if ($object->getEntityTypeId() == 'node_type') { + $index = 'content'; + } + else { + $index = $object->getThirdPartySetting('acquia_cms_search', 'search_index'); + } return $index ? $this->indexStorage->load($index) : NULL; }