diff --git a/search_api_pantheon.module b/search_api_pantheon.module index 1848de5d..25d8c7a7 100644 --- a/search_api_pantheon.module +++ b/search_api_pantheon.module @@ -12,7 +12,15 @@ function search_api_pantheon_form_alter(&$form, &$form_state, $form_id) { function search_api_pantheon_form_submit($form, &$form_state) { $rl = \Drupal::service("search_api_pantheon.reload"); + $messenger = \Drupal::service("messenger")->get("search_api_pantheon"); + if ( + !$rl instanceof \Drupal\search_api_pantheon\ReloadInterface + || !$messenger instanceof \Drupal\Core\Messenger\MessengerInterface + ) { + $this->logger->error('Service failure. Service not found.'); + return; + } $rl->reloadServer() ? - drupal_set_message(t('Core reloaded successfully.')) : - drupal_set_message(t('Core reload failed.'), 'error'); + $messenger->addStatus(t('Core reloaded successfully.')) : + $messenger->addError((t('Core reload failed.')); } diff --git a/src/Plugin/SolrConnector/PantheonSolrConnector.php b/src/Plugin/SolrConnector/PantheonSolrConnector.php index 591c81ba..b487becc 100644 --- a/src/Plugin/SolrConnector/PantheonSolrConnector.php +++ b/src/Plugin/SolrConnector/PantheonSolrConnector.php @@ -15,6 +15,7 @@ use Drupal\search_api_pantheon\Services\SolariumClient as PantheonSolariumClient; use Drupal\Core\Datetime\DateFormatterInterface; use Drupal\search_api_pantheon\Services\Reload; +use Drupal\Core\Messenger\MessengerInterface; /** * Pantheon Solr connector. @@ -61,7 +62,7 @@ class PantheonSolrConnector extends SolrConnectorPluginBase implements * * @var \Drupal\Core\Messenger\MessengerInterface */ - protected $messenger; + protected MessengerInterface $messenger; /** * The container.