Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / search / src / Form / ReindexConfirm.php
1 <?php
2
3 namespace Drupal\search\Form;
4
5 use Drupal\Core\Form\ConfirmFormBase;
6 use Drupal\Core\Form\FormStateInterface;
7 use Drupal\Core\Url;
8
9 /**
10  * Provides the search reindex confirmation form.
11  */
12 class ReindexConfirm extends ConfirmFormBase {
13
14   /**
15    * {@inheritdoc}
16    */
17   public function getFormId() {
18     return 'search_reindex_confirm';
19   }
20
21   /**
22    * {@inheritdoc}
23    */
24   public function getQuestion() {
25     return $this->t('Are you sure you want to re-index the site?');
26   }
27
28   /**
29    * {@inheritdoc}
30    */
31   public function getDescription() {
32     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.");
33   }
34
35   /**
36    * {@inheritdoc}
37    */
38   public function getConfirmText() {
39     return $this->t('Re-index site');
40   }
41
42   /**
43    * {@inheritdoc}
44    */
45   public function getCancelText() {
46     return $this->t('Cancel');
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function getCancelUrl() {
53     return new Url('entity.search_page.collection');
54   }
55
56   /**
57    * {@inheritdoc}
58    */
59   public function submitForm(array &$form, FormStateInterface $form_state) {
60     if ($form['confirm']) {
61       // Ask each active search page to mark itself for re-index.
62       $search_page_repository = \Drupal::service('search.search_page_repository');
63       foreach ($search_page_repository->getIndexableSearchPages() as $entity) {
64         $entity->getPlugin()->markForReindex();
65       }
66       drupal_set_message($this->t('All search indexes will be rebuilt.'));
67       $form_state->setRedirectUrl($this->getCancelUrl());
68     }
69   }
70
71 }