You are here

class OneBoxResult in Google Search Appliance 8

Defines a value object for a one-box result.

Hierarchy

Expanded class hierarchy of OneBoxResult

1 file declares its use of OneBoxResult
Parser.php in src/Service/Parser.php

File

src/SearchResults/OneBoxResult.php, line 8

Namespace

Drupal\google_appliance\SearchResults
View source
class OneBoxResult {

  /**
   * Array of field values keyed by field name.
   *
   * @var string[]
   */
  protected $fields = [];

  /**
   * Absolute URL.
   *
   * @var string
   */
  protected $absoluteUrl;

  /**
   * Title.
   *
   * @var string
   */
  protected $title;

  /**
   * Constructs a new OneBoxResult object.
   *
   * @param string $absoluteUrl
   *   Absolute URL.
   * @param string $title
   *   Title.
   */
  public function __construct($absoluteUrl, $title) {
    $this->absoluteUrl = $absoluteUrl;
    $this->title = $title;
  }

  /**
   * Add field value.
   *
   * @param string $name
   *   Field name.
   * @param string $value
   *   Field value.
   *
   * @return $this
   */
  public function addFieldValue($name, $value) {
    $this->fields[$name] = $value;
    return $this;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
OneBoxResult::$absoluteUrl protected property Absolute URL.
OneBoxResult::$fields protected property Array of field values keyed by field name.
OneBoxResult::$title protected property Title.
OneBoxResult::addFieldValue public function Add field value.
OneBoxResult::__construct public function Constructs a new OneBoxResult object.