summaryrefslogtreecommitdiffstats
path: root/core/modules/search
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/search')
-rw-r--r--core/modules/search/src/Controller/SearchController.php8
-rw-r--r--core/modules/search/src/Form/ReindexConfirm.php2
-rw-r--r--core/modules/search/src/Form/SearchPageAddForm.php2
-rw-r--r--core/modules/search/src/Form/SearchPageEditForm.php2
-rw-r--r--core/modules/search/src/SearchPageListBuilder.php20
-rw-r--r--core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php2
-rw-r--r--core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module4
7 files changed, 26 insertions, 14 deletions
diff --git a/core/modules/search/src/Controller/SearchController.php b/core/modules/search/src/Controller/SearchController.php
index e0b6466..f6449df 100644
--- a/core/modules/search/src/Controller/SearchController.php
+++ b/core/modules/search/src/Controller/SearchController.php
@@ -104,7 +104,7 @@ class SearchController extends ControllerBase {
else {
// The search not being executable means that no keywords or other
// conditions were entered.
- drupal_set_message($this->t('Please enter some keywords.'), 'error');
+ $this->messenger()->addError($this->t('Please enter some keywords.'));
}
}
@@ -206,10 +206,10 @@ class SearchController extends ControllerBase {
$search_page->$op()->save();
if ($op == 'enable') {
- drupal_set_message($this->t('The %label search page has been enabled.', ['%label' => $search_page->label()]));
+ $this->messenger()->addStatus($this->t('The %label search page has been enabled.', ['%label' => $search_page->label()]));
}
elseif ($op == 'disable') {
- drupal_set_message($this->t('The %label search page has been disabled.', ['%label' => $search_page->label()]));
+ $this->messenger()->addStatus($this->t('The %label search page has been disabled.', ['%label' => $search_page->label()]));
}
$url = $search_page->urlInfo('collection');
@@ -229,7 +229,7 @@ class SearchController extends ControllerBase {
// Set the default page to this search page.
$this->searchPageRepository->setDefaultSearchPage($search_page);
- drupal_set_message($this->t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $search_page->label()]));
+ $this->messenger()->addStatus($this->t('The default search page is now %label. Be sure to check the ordering of your search pages.', ['%label' => $search_page->label()]));
return $this->redirect('entity.search_page.collection');
}
diff --git a/core/modules/search/src/Form/ReindexConfirm.php b/core/modules/search/src/Form/ReindexConfirm.php
index 2a30cb5..a9a2cd0 100644
--- a/core/modules/search/src/Form/ReindexConfirm.php
+++ b/core/modules/search/src/Form/ReindexConfirm.php
@@ -65,7 +65,7 @@ class ReindexConfirm extends ConfirmFormBase {
foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
$entity->getPlugin()->markForReindex();
}
- drupal_set_message($this->t('All search indexes will be rebuilt.'));
+ $this->messenger()->addStatus($this->t('All search indexes will be rebuilt.'));
$form_state->setRedirectUrl($this->getCancelUrl());
}
}
diff --git a/core/modules/search/src/Form/SearchPageAddForm.php b/core/modules/search/src/Form/SearchPageAddForm.php
index 6f5c142..492d6c0 100644
--- a/core/modules/search/src/Form/SearchPageAddForm.php
+++ b/core/modules/search/src/Form/SearchPageAddForm.php
@@ -41,7 +41,7 @@ class SearchPageAddForm extends SearchPageFormBase {
parent::save($form, $form_state);
- drupal_set_message($this->t('The %label search page has been added.', ['%label' => $this->entity->label()]));
+ $this->messenger()->addStatus($this->t('The %label search page has been added.', ['%label' => $this->entity->label()]));
}
}
diff --git a/core/modules/search/src/Form/SearchPageEditForm.php b/core/modules/search/src/Form/SearchPageEditForm.php
index afbcfbc..28fda7f 100644
--- a/core/modules/search/src/Form/SearchPageEditForm.php
+++ b/core/modules/search/src/Form/SearchPageEditForm.php
@@ -26,7 +26,7 @@ class SearchPageEditForm extends SearchPageFormBase {
public function save(array $form, FormStateInterface $form_state) {
parent::save($form, $form_state);
- drupal_set_message($this->t('The %label search page has been updated.', ['%label' => $this->entity->label()]));
+ $this->messenger()->addStatus($this->t('The %label search page has been updated.', ['%label' => $this->entity->label()]));
}
}
diff --git a/core/modules/search/src/SearchPageListBuilder.php b/core/modules/search/src/SearchPageListBuilder.php
index 9a8f6de..9442b69 100644
--- a/core/modules/search/src/SearchPageListBuilder.php
+++ b/core/modules/search/src/SearchPageListBuilder.php
@@ -10,6 +10,7 @@ use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Form\ConfigFormBaseTrait;
use Drupal\Core\Form\FormInterface;
use Drupal\Core\Form\FormStateInterface;
+use Drupal\Core\Messenger\MessengerInterface;
use Drupal\Core\Url;
use Symfony\Component\DependencyInjection\ContainerInterface;
@@ -43,6 +44,13 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
protected $searchManager;
/**
+ * The messenger.
+ *
+ * @var \Drupal\Core\Messenger\MessengerInterface
+ */
+ protected $messenger;
+
+ /**
* Constructs a new SearchPageListBuilder object.
*
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
@@ -53,11 +61,14 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
* The search plugin manager.
* @param \Drupal\Core\Config\ConfigFactoryInterface $config_factory
* The factory for configuration objects.
+ * @param \Drupal\Core\Messenger\MessengerInterface $messenger
+ * The messenger.
*/
- public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, SearchPluginManager $search_manager, ConfigFactoryInterface $config_factory) {
+ public function __construct(EntityTypeInterface $entity_type, EntityStorageInterface $storage, SearchPluginManager $search_manager, ConfigFactoryInterface $config_factory, MessengerInterface $messenger) {
parent::__construct($entity_type, $storage);
$this->configFactory = $config_factory;
$this->searchManager = $search_manager;
+ $this->messenger = $messenger;
}
/**
@@ -68,7 +79,8 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
$entity_type,
$container->get('entity.manager')->getStorage($entity_type->id()),
$container->get('plugin.manager.search'),
- $container->get('config.factory')
+ $container->get('config.factory'),
+ $container->get('messenger')
);
}
@@ -333,7 +345,7 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
$search_settings->set('index.overlap_cjk', $form_state->getValue('overlap_cjk'));
// Specifically mark items in the default index for reindexing, since
// these settings are used in the search_index() function.
- drupal_set_message($this->t('The default search index will be rebuilt.'));
+ $this->messenger->addStatus($this->t('The default search index will be rebuilt.'));
search_mark_for_reindex();
}
@@ -342,7 +354,7 @@ class SearchPageListBuilder extends DraggableListBuilder implements FormInterfac
->set('logging', $form_state->getValue('logging'))
->save();
- drupal_set_message($this->t('The configuration options have been saved.'));
+ $this->messenger->addStatus($this->t('The configuration options have been saved.'));
}
/**
diff --git a/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php b/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php
index b1e26ca..5f13ee9 100644
--- a/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php
+++ b/core/modules/search/tests/modules/search_embedded_form/src/Form/SearchEmbeddedForm.php
@@ -50,7 +50,7 @@ class SearchEmbeddedForm extends FormBase {
$state = \Drupal::state();
$submit_count = (int) $state->get('search_embedded_form.submit_count');
$state->set('search_embedded_form.submit_count', $submit_count + 1);
- drupal_set_message($this->t('Test form was submitted'));
+ $this->messenger()->addStatus($this->t('Test form was submitted'));
}
}
diff --git a/core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module b/core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
index c7d9624..3833060 100644
--- a/core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
+++ b/core/modules/search/tests/modules/search_langcode_test/search_langcode_test.module
@@ -19,13 +19,13 @@ function search_langcode_test_search_preprocess($text, $langcode = NULL) {
// Prints the langcode for testPreprocessLangcode() and adds some
// extra text.
else {
- drupal_set_message('Langcode Preprocess Test: ' . $langcode);
+ \Drupal::messenger()->addStatus('Langcode Preprocess Test: ' . $langcode);
$text .= 'Additional text';
}
}
// Prints the langcode for testPreprocessLangcode().
elseif (isset($langcode)) {
- drupal_set_message('Langcode Preprocess Test: ' . $langcode);
+ \Drupal::messenger()->addStatus('Langcode Preprocess Test: ' . $langcode);
// Preprocessing for the excerpt test.
if ($langcode == 'ex') {