Commit 26e59652 authored by catch's avatar catch
Browse files

Issue #1946452 by splatio: Convert confirm_form() in search.admin.inc to the new form interface.

parent bce56a17
<?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;
}
}
}
......@@ -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.
*/
......
......@@ -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
......
search_reindex_confirm:
pattern: '/admin/config/search/settings/reindex'
defaults:
_form: 'Drupal\search\Form\ReindexConfirm'
requirements:
_permission: 'administer search'
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment