diff --git a/search_api_pantheon.module b/search_api_pantheon.module index 3ae685eb..26bd8005 100644 --- a/search_api_pantheon.module +++ b/search_api_pantheon.module @@ -4,23 +4,3 @@ * @file */ -/** - * @issue BUGS-4278 - * - * Implements hook_search_api_solr_config_files_alter(). - * - * Remember to post schema after any changes to the XML files here. - */ -function search_api_pantheon_search_api_solr_config_files_alter(array &$files, string $lucene_match_version, string $server_id = '') { - // Append at the end of the file. - $solrcore_properties = explode(PHP_EOL, $files['solrcore.properties']); - // Remove the solr.install.dir if it exists - foreach ($solrcore_properties as $key => $property) { - if (substr($property, 0, 16) == 'solr.install.dir') { - unset($solrcore_properties[$key]); - } - } - // Remove the solrcore.properties file from the upload - // This file is causing undue issues with core restarts - unset($files['solrcore.properties']); -} diff --git a/search_api_pantheon.services.yml b/search_api_pantheon.services.yml index 34776a37..f20aa923 100755 --- a/search_api_pantheon.services.yml +++ b/search_api_pantheon.services.yml @@ -11,3 +11,7 @@ services: search_api_pantheon.solarium_client: class: Drupal\search_api_pantheon\Services\SolariumClient arguments: ['@search_api_pantheon.pantheon_guzzle', '@search_api_pantheon.endpoint', '@logger.factory', '@event_dispatcher'] + search_api_pantheon.event_subscriber: + class: Drupal\search_api_pantheon\EventSubscriber\SearchApiPantheonSolrConfigFilesAlter + tags: + - { name: event_subscriber } diff --git a/src/EventSubscriber/SearchApiPantheonSolrConfigFilesAlter.php b/src/EventSubscriber/SearchApiPantheonSolrConfigFilesAlter.php new file mode 100644 index 00000000..9d228dd2 --- /dev/null +++ b/src/EventSubscriber/SearchApiPantheonSolrConfigFilesAlter.php @@ -0,0 +1,51 @@ +getConfigFiles(); + // Append at the end of the file. + $solrcore_properties = explode(PHP_EOL, $files['solrcore.properties']); + // Remove the solr.install.dir if it exists + foreach ($solrcore_properties as $key => $property) { + if (substr($property, 0, 16) == 'solr.install.dir') { + unset($solrcore_properties[$key]); + } + } + // Remove the solrcore.properties file from the upload + // This file is causing undue issues with core restarts + unset($files['solrcore.properties']); + + $event->setConfigFiles($files); + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents(): array { + return [ + 'Drupal\search_api_solr\Event\PostConfigFilesGenerationEvent' => ['onPostConfigFilesGenerationEvent'], + ]; + } + +}