Same filename and directory in other branches
- 8.9.x core/modules/search/src/Form/ReindexConfirm.php
- 9 core/modules/search/src/Form/ReindexConfirm.php
Namespace
Drupal\search\Form
File
core/modules/search/src/Form/ReindexConfirm.php
View source
<?php
namespace Drupal\search\Form;
use Drupal\Core\Form\ConfirmFormBase;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Url;
class ReindexConfirm extends ConfirmFormBase {
public function getFormId() {
return 'search_reindex_confirm';
}
public function getQuestion() {
return $this
->t('Are you sure you want to re-index the site?');
}
public function getDescription() {
return $this
->t("This will re-index content in the search indexes of all active search pages. Searching will continue to work, but new content won't be indexed until all existing content has been re-indexed. This action cannot be undone.");
}
public function getConfirmText() {
return $this
->t('Re-index site');
}
public function getCancelText() {
return $this
->t('Cancel');
}
public function getCancelUrl() {
return new Url('entity.search_page.collection');
}
public function submitForm(array &$form, FormStateInterface $form_state) {
if ($form['confirm']) {
$search_page_repository = \Drupal::service('search.search_page_repository');
foreach ($search_page_repository
->getIndexableSearchPages() as $entity) {
$entity
->getPlugin()
->markForReindex();
}
$this
->messenger()
->addStatus($this
->t('All search indexes will be rebuilt.'));
$form_state
->setRedirectUrl($this
->getCancelUrl());
}
}
}
Classes