QueryTypePluginBase.php in Facets 8
File
src/QueryType/QueryTypePluginBase.php
View source
<?php
namespace Drupal\facets\QueryType;
use Drupal\Component\Plugin\ConfigurableInterface;
use Drupal\Component\Plugin\DependentPluginInterface;
use Drupal\Core\Entity\DependencyTrait;
use Drupal\Core\Plugin\PluginBase;
abstract class QueryTypePluginBase extends PluginBase implements QueryTypeInterface, ConfigurableInterface, DependentPluginInterface {
use DependencyTrait;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->query = $this->configuration['query'];
$this->facet = $this->configuration['facet'];
$this->results = !empty($this->configuration['results']) ? $this->configuration['results'] : [];
}
protected $query;
protected $facet;
protected $results;
protected $linkGenerator;
public function defaultConfiguration() {
return [];
}
public function getConfiguration() {
return $this->configuration;
}
public function setConfiguration(array $configuration) {
$this->configuration = $configuration + $this
->defaultConfiguration();
}
public function calculateDependencies() {
$this
->addDependency('module', $this
->getPluginDefinition()['provider']);
return $this->dependencies;
}
protected function getFacetOptions() {
return [
'field' => $this->facet
->getFieldIdentifier(),
'limit' => $this->facet
->getHardLimit(),
'operator' => $this->facet
->getQueryOperator(),
'min_count' => $this->facet
->getMinCount(),
'missing' => FALSE,
'query_type' => $this
->getPluginId(),
];
}
}