Skip to content

Commit

Permalink
fix messenger error
Browse files Browse the repository at this point in the history
  • Loading branch information
stovak committed Nov 18, 2024
1 parent 4c287d1 commit f51f43b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
12 changes: 10 additions & 2 deletions search_api_pantheon.module
Original file line number Diff line number Diff line change
Expand Up @@ -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.'));
}
3 changes: 2 additions & 1 deletion src/Plugin/SolrConnector/PantheonSolrConnector.php
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -61,7 +62,7 @@ class PantheonSolrConnector extends SolrConnectorPluginBase implements
*
* @var \Drupal\Core\Messenger\MessengerInterface
*/
protected $messenger;
protected MessengerInterface $messenger;

/**
* The container.
Expand Down

0 comments on commit f51f43b

Please sign in to comment.