Security update to Drupal 8.4.6
[yaffs-website] / web / core / modules / search / src / Plugin / views / row / SearchRow.php
1 <?php
2
3 namespace Drupal\search\Plugin\views\row;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\Plugin\views\row\RowPluginBase;
7
8 /**
9  * Row handler plugin for displaying search results.
10  *
11  * @ViewsRow(
12  *   id = "search_view",
13  *   title = @Translation("Search results"),
14  *   help = @Translation("Provides a row plugin to display search results.")
15  * )
16  */
17 class SearchRow extends RowPluginBase {
18
19   /**
20    * {@inheritdoc}
21    */
22   protected function defineOptions() {
23     $options = parent::defineOptions();
24
25     $options['score'] = ['default' => TRUE];
26
27     return $options;
28   }
29
30   /**
31    * {@inheritdoc}
32    */
33   public function buildOptionsForm(&$form, FormStateInterface $form_state) {
34     $form['score'] = [
35       '#type' => 'checkbox',
36       '#title' => $this->t('Display score'),
37       '#default_value' => $this->options['score'],
38     ];
39   }
40
41   /**
42    * {@inheritdoc}
43    */
44   public function render($row) {
45     return [
46       '#theme' => $this->themeFunctions(),
47       '#view' => $this->view,
48       '#options' => $this->options,
49       '#row' => $row,
50     ];
51   }
52
53 }