Chris@0: t('Are you sure you want to re-index the site?'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getDescription() { Chris@0: 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."); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getConfirmText() { Chris@0: return $this->t('Re-index site'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getCancelText() { Chris@0: return $this->t('Cancel'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function getCancelUrl() { Chris@0: return new Url('entity.search_page.collection'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * {@inheritdoc} Chris@0: */ Chris@0: public function submitForm(array &$form, FormStateInterface $form_state) { Chris@0: if ($form['confirm']) { Chris@0: // Ask each active search page to mark itself for re-index. Chris@0: $search_page_repository = \Drupal::service('search.search_page_repository'); Chris@0: foreach ($search_page_repository->getIndexableSearchPages() as $entity) { Chris@0: $entity->getPlugin()->markForReindex(); Chris@0: } Chris@17: $this->messenger()->addStatus($this->t('All search indexes will be rebuilt.')); Chris@0: $form_state->setRedirectUrl($this->getCancelUrl()); Chris@0: } Chris@0: } Chris@0: Chris@0: }