diff --git a/core/modules/search/lib/Drupal/search/Form/ReindexConfirm.php b/core/modules/search/lib/Drupal/search/Form/ReindexConfirm.php new file mode 100644 index 0000000000000000000000000000000000000000..0984b0bf5e09d4184766d3eb7138e0fb4f371daf --- /dev/null +++ b/core/modules/search/lib/Drupal/search/Form/ReindexConfirm.php @@ -0,0 +1,70 @@ +<?php + +/** + * @file + * Contains \Drupal\search\Form\ReindexConfirm. + */ + +namespace Drupal\search\Form; + +use Drupal\Core\Form\ConfirmFormBase; + +/** + * Provides the search reindex confirmation form. + */ +class ReindexConfirm extends ConfirmFormBase { + + /** + * Implements \Drupal\Core\Form\FormInterface::getFormID(). + */ + public function getFormID() { + return 'search_reindex_confirm'; + } + + /** + * Implements \Drupal\Core\Form\ConfirmFormBase::getQuestion(). + */ + public function getQuestion() { + return t('Are you sure you want to re-index the site?'); + } + + /** + * Overrides \Drupal\Core\Form\ConfirmFormBase::getDescription(). + */ + public function getDescription() { + return t('The search index is not cleared but systematically updated to reflect the new settings. 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.'); + } + + /** + * Overrides \Drupal\Core\Form\ConfirmFormBase::getConfirmText(). + */ + public function getConfirmText() { + return t('Re-index site'); + } + + /** + * Overrides \Drupal\Core\Form\ConfirmFormBase::getCancelText(). + */ + public function getCancelText() { + return t('Cancel'); + } + + /** + * Implements \Drupal\Core\Form\ConfirmFormBase::getCancelPath(). + */ + public function getCancelPath() { + return 'admin/config/search/settings'; + } + + /** + * Implements \Drupal\Core\Form\FormInterface::submitForm(). + */ + public function submitForm(array &$form, array &$form_state) { + if ($form['confirm']) { + search_reindex(); + drupal_set_message(t('The index will be rebuilt.')); + $form_state['redirect'] = 'admin/config/search/settings'; + return; + } + } +} diff --git a/core/modules/search/search.admin.inc b/core/modules/search/search.admin.inc index a63cf47061d8f189ddbad9850e3add4f1ce08d8b..6f0825fc8325c0e5d5cdf409c6504373d955ddb3 100644 --- a/core/modules/search/search.admin.inc +++ b/core/modules/search/search.admin.inc @@ -7,29 +7,6 @@ use Drupal\Component\Utility\NestedArray; -/** - * Menu callback: Confirms wiping of the index. - */ -function search_reindex_confirm() { - return confirm_form(array(), t('Are you sure you want to re-index the site?'), - 'admin/config/search/settings', t('The search index is not cleared but systematically updated to reflect the new settings. 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.'), t('Re-index site'), t('Cancel')); -} - -/** - * Form submission handler for search_reindex_confirm(). - * - * @see search_reindex() - * @see search_reindex_confirm() - */ -function search_reindex_confirm_submit(&$form, &$form_state) { - if ($form['confirm']) { - search_reindex(); - drupal_set_message(t('The index will be rebuilt.')); - $form_state['redirect'] = 'admin/config/search/settings'; - return; - } -} - /** * Helper function to get real module names. */ diff --git a/core/modules/search/search.module b/core/modules/search/search.module index 85e58d358c2c1afcbb1a6e531ba53f5f3ff6c1bc..6dd68d9520492c555e7d5514eb6d48930970ba8d 100644 --- a/core/modules/search/search.module +++ b/core/modules/search/search.module @@ -165,11 +165,8 @@ function search_menu() { ); $items['admin/config/search/settings/reindex'] = array( 'title' => 'Clear index', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('search_reindex_confirm'), - 'access arguments' => array('administer search'), + 'route_name' => 'search_reindex_confirm', 'type' => MENU_VISIBLE_IN_BREADCRUMB, - 'file' => 'search.admin.inc', ); // Add paths for searching. We add each module search path twice: once without diff --git a/core/modules/search/search.routing.yml b/core/modules/search/search.routing.yml new file mode 100644 index 0000000000000000000000000000000000000000..5521e187a111eee31f2b4154cfd9a9112eddcc44 --- /dev/null +++ b/core/modules/search/search.routing.yml @@ -0,0 +1,6 @@ +search_reindex_confirm: + pattern: '/admin/config/search/settings/reindex' + defaults: + _form: 'Drupal\search\Form\ReindexConfirm' + requirements: + _permission: 'administer search'