You are here

class Synonym in Google Search Appliance 8

Defines a value object for a synonym.

Hierarchy

  • class \Drupal\google_appliance\SearchResults\Synonym

Expanded class hierarchy of Synonym

3 files declare their use of Synonym
google_appliance.api.php in ./google_appliance.api.php
Hook documentation.
Parser.php in src/Service/Parser.php
TestSearch.php in tests/modules/google_appliance_test/src/TestSearch.php

File

src/SearchResults/Synonym.php, line 12

Namespace

Drupal\google_appliance\SearchResults
View source
class Synonym {

  /**
   * Description.
   *
   * @var string
   */
  protected $description;

  /**
   * URL.
   *
   * @var string
   */
  protected $url;

  /**
   * Constructs a new Synonym object.
   *
   * @param string $description
   *   Synonym description.
   * @param string $url
   *   Synonym URL.
   */
  public function __construct($description, $url) {
    $this->description = $description;
    $this->url = $url;
  }

  /**
   * Gets value of description.
   *
   * @return string
   *   Value of description
   */
  public function getDescription() {
    return $this->description;
  }

  /**
   * Gets value of url.
   *
   * @return string
   *   Value of url
   */
  public function getUrl() {
    return $this->url;
  }

  /**
   * Gets synonym as link.
   *
   * @return \Drupal\Core\Link
   *   Link object.
   */
  public function getLink() {
    return Link::fromTextAndUrl($this->description, Url::fromRoute(SearchViewRoute::ROUTE_NAME, [
      'search_query' => $this->url,
    ]));
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Synonym::$description protected property Description.
Synonym::$url protected property URL.
Synonym::getDescription public function Gets value of description.
Synonym::getLink public function Gets synonym as link.
Synonym::getUrl public function Gets value of url.
Synonym::__construct public function Constructs a new Synonym object.