SearchRow.php

Same filename and directory in other branches
  1. 9 core/modules/search/src/Plugin/views/row/SearchRow.php
  2. 8.9.x core/modules/search/src/Plugin/views/row/SearchRow.php
  3. 10 core/modules/search/src/Plugin/views/row/SearchRow.php

Namespace

Drupal\search\Plugin\views\row

File

core/modules/search/src/Plugin/views/row/SearchRow.php

View source
<?php

namespace Drupal\search\Plugin\views\row;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\views\Attribute\ViewsRow;
use Drupal\views\Plugin\views\row\RowPluginBase;

/**
 * Row handler plugin for displaying search results.
 */
class SearchRow extends RowPluginBase {
  
  /**
   * {@inheritdoc}
   */
  protected function defineOptions() {
    $options = parent::defineOptions();
    $options['score'] = [
      'default' => TRUE,
    ];
    return $options;
  }
  
  /**
   * {@inheritdoc}
   */
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    $form['score'] = [
      '#type' => 'checkbox',
      '#title' => $this->t('Display score'),
      '#default_value' => $this->options['score'],
    ];
  }
  
  /**
   * {@inheritdoc}
   */
  public function render($row) {
    return [
      '#theme' => $this->themeFunctions(),
      '#view' => $this->view,
      '#options' => $this->options,
      '#row' => $row,
    ];
  }

}

Classes

Title Deprecated Summary
SearchRow Row handler plugin for displaying search results.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.