You are here

trait BackendTrait in Search API Solr 4.x

Same name in this branch
  1. 4.x src/Controller/BackendTrait.php \Drupal\search_api_solr\Controller\BackendTrait
  2. 4.x src/Plugin/search_api_autocomplete/suggester/BackendTrait.php \Drupal\search_api_solr\Plugin\search_api_autocomplete\suggester\BackendTrait
Same name and namespace in other branches
  1. 8.3 src/Controller/BackendTrait.php \Drupal\search_api_solr\Controller\BackendTrait

Provides a listing of Solr Entities.

Hierarchy

File

src/Controller/BackendTrait.php, line 11

Namespace

Drupal\search_api_solr\Controller
View source
trait BackendTrait {

  /**
   * The Search API server backend.
   *
   * @var \Drupal\search_api_solr\SolrBackendInterface
   */
  protected $backend;

  /**
   * The Search API server ID.
   *
   * @var string
   */
  protected $serverId = '';

  /**
   * The Solr minimum version string.
   *
   * @var string
   */
  protected $assumedMinimumVersion = '';

  /**
   * Reset.
   *
   * @var bool
   */
  protected $reset = FALSE;

  /**
   * Sets the Search API server and calls setBackend() afterwards.
   *
   * @param \Drupal\search_api\ServerInterface $server
   *   The Search API server entity.
   *
   * @throws \Drupal\search_api\SearchApiException
   */
  public function setServer(ServerInterface $server) {

    /* @var SolrBackendInterface $backend */
    $backend = $server
      ->getBackend();
    $this
      ->setBackend($backend);
    $this->serverId = $server
      ->id();
  }

  /**
   * Sets the Search API server backend.
   *
   * @param \Drupal\search_api_solr\SolrBackendInterface $backend
   *   The Search API server backend.
   */
  public function setBackend(SolrBackendInterface $backend) {
    $this->backend = $backend;
    $this->reset = TRUE;
  }

  /**
   * Returns the Search API server backend.
   *
   * @return \Drupal\search_api_solr\SolrBackendInterface
   *   The Search API server backend.
   */
  protected function getBackend() {
    return $this->backend;
  }

  /**
   * Set assumed minimum version.
   *
   * @param \Drupal\search_api_solr\Controller\string $assumedMinimumVersion
   *   Assumed minimum version.
   */
  public function setAssumedMinimumVersion(string $assumedMinimumVersion) {
    $this->assumedMinimumVersion = $assumedMinimumVersion;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
BackendTrait::$assumedMinimumVersion protected property The Solr minimum version string.
BackendTrait::$backend protected property The Search API server backend.
BackendTrait::$reset protected property Reset.
BackendTrait::$serverId protected property The Search API server ID.
BackendTrait::getBackend protected function Returns the Search API server backend.
BackendTrait::setAssumedMinimumVersion public function Set assumed minimum version.
BackendTrait::setBackend public function Sets the Search API server backend.
BackendTrait::setServer public function Sets the Search API server and calls setBackend() afterwards.