public function getCancelUrl() { return new Url('entity.search_page.collection'
);
} /**
* {@inheritdoc}
*/
public function submitForm(array &
$form, FormStateInterface
$form_state) { if ($form['confirm'
]) { // Ask each active search page to mark itself for re-index.
$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());
} }}