TestProcessor.php in Search API 8
File
tests/search_api_test/src/Plugin/search_api/processor/TestProcessor.php
View source
<?php
namespace Drupal\search_api_test\Plugin\search_api\processor;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Processor\ProcessorPluginBase;
use Drupal\search_api\Query\QueryInterface;
use Drupal\search_api\Query\ResultSetInterface;
use Drupal\search_api_test\TestPluginTrait;
class TestProcessor extends ProcessorPluginBase {
use TestPluginTrait;
public static function supportsIndex(IndexInterface $index) {
$key = 'search_api_test.processor.method.supportsIndex';
if ($method = \Drupal::state()
->get($key)) {
return call_user_func($method, $index);
}
return TRUE;
}
public function supportsStage($stage_identifier) {
return TRUE;
}
public function preIndexSave() {
$this
->logMethodCall(__FUNCTION__, func_get_args());
}
public function alterIndexedItems(array &$items) {
$this
->logMethodCall(__FUNCTION__, func_get_args());
}
public function preprocessIndexItems(array $items) {
$this
->logMethodCall(__FUNCTION__, func_get_args());
}
public function preprocessSearchQuery(QueryInterface $query) {
$this
->logMethodCall(__FUNCTION__, func_get_args());
}
public function postprocessSearchResults(ResultSetInterface $results) {
$this
->logMethodCall(__FUNCTION__, func_get_args());
}
public function calculateDependencies() {
$dependencies = $this->configuration;
unset($dependencies['weights']);
return $dependencies;
}
public function onDependencyRemoval(array $dependencies) {
$remove = $this
->getReturnValue(__FUNCTION__, FALSE);
if ($remove) {
$this->configuration = [];
}
return $remove;
}
}
Classes
Name |
Description |
TestProcessor |
Provides a processor with dependencies, for the dependency removal tests. |