You are here

class AddSearchMetaEvent in JSON:API Search API 8

Allows for other sources to modify the meta portion of the search.

Hierarchy

  • class \Drupal\jsonapi_search_api\Event\AddSearchMetaEvent extends \Symfony\Component\EventDispatcher\Event

Expanded class hierarchy of AddSearchMetaEvent

2 files declare their use of AddSearchMetaEvent
AddSearchMetaEventSubscriber.php in modules/jsonapi_search_api_facets/src/EventSubscriber/AddSearchMetaEventSubscriber.php
IndexResource.php in src/Resource/IndexResource.php

File

src/Event/AddSearchMetaEvent.php, line 12

Namespace

Drupal\jsonapi_search_api\Event
View source
class AddSearchMetaEvent extends Event {

  /**
   * Meta information to be added to the search.
   *
   * @var array
   */
  protected $meta;

  /**
   * The query that was executed.
   *
   * @var \Drupal\search_api\Query\QueryInterface
   */
  protected $query;

  /**
   * Results returned from the search.
   *
   * @var \Drupal\search_api\Query\ResultSetInterface
   */
  protected $results;

  /**
   * AddSearchMetaEvent constructor.
   *
   * @param \Drupal\search_api\Query\QueryInterface $query
   *   Query that was executed.
   * @param \Drupal\search_api\Query\ResultSetInterface $results
   *   Results returned from the search.
   * @param array $meta
   *   An array representing the meta portion of the JSON:API response.
   */
  public function __construct(QueryInterface $query, ResultSetInterface $results, array $meta) {
    $this->query = $query;
    $this->results = $results;
    $this->meta = $meta;
  }

  /**
   * Getter for the query.
   *
   * @return \Drupal\search_api\Query\QueryInterface
   *   The query.
   */
  public function getQuery() {
    return $this->query;
  }

  /**
   * Getter for the results.
   *
   * @return \Drupal\search_api\Query\ResultSetInterface
   *   The results.
   */
  public function getResults() {
    return $this->results;
  }

  /**
   * Getter for the meta.
   *
   * @return array
   *   The meta to be used.
   */
  public function getMeta() {
    return $this->meta;
  }

  /**
   * Sets an entry in the meta.
   *
   * @param string $key
   *   The key to be used in the meta portion of the JSON:API response.
   * @param string|array $value
   *   The value to be used in the JSON:API response.
   */
  public function setMeta($key, $value) {
    $this->meta[$key] = $value;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AddSearchMetaEvent::$meta protected property Meta information to be added to the search.
AddSearchMetaEvent::$query protected property The query that was executed.
AddSearchMetaEvent::$results protected property Results returned from the search.
AddSearchMetaEvent::getMeta public function Getter for the meta.
AddSearchMetaEvent::getQuery public function Getter for the query.
AddSearchMetaEvent::getResults public function Getter for the results.
AddSearchMetaEvent::setMeta public function Sets an entry in the meta.
AddSearchMetaEvent::__construct public function AddSearchMetaEvent constructor.