Skip to content
Snippets Groups Projects
Commit dbfcbf0a authored by Jens Beltofte's avatar Jens Beltofte
Browse files

Issue #3203188 by yoerioptr, beltofte: Search API compatibility

parent b4e34835
No related branches found
No related tags found
No related merge requests found
......@@ -6,7 +6,9 @@ use Drupal\Core\Entity\ContentEntityInterface;
use Drupal\entity_language_fallback\FallbackControllerInterface;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\search_api\Entity\Index;
use Drupal\search_api\IndexInterface;
use Drupal\search_api\Plugin\search_api\datasource\ContentEntity;
use Drupal\search_api\Plugin\search_api\datasource\ContentEntityTrackingManager;
use Drupal\search_api\Utility\Utility;
use Symfony\Component\DependencyInjection\ContainerInterface;
......@@ -187,4 +189,35 @@ class ContentEntityFallback extends ContentEntity {
$this->fallbackController = $controller;
}
/**
* Filters a set of datasource-specific item IDs.
*
* Returns only those item IDs that are valid for the given datasource and
* index. This method only checks the item language, though – whether an
* entity with that ID actually exists, or whether it has a bundle included
* for that datasource, is not verified.
*
* Note: ContentEntity::filterValidItemIds() is deprecated in Search API
* and the "wrapper"-method is only implemented here as a backwards
* compatability solution.
*
* @param \Drupal\search_api\IndexInterface $index
* The index for which to validate.
* @param string $datasource_id
* The ID of the datasource on the index for which to validate.
* @param string[] $item_ids
* The item IDs to be validated.
*
* @return string[]
* All given item IDs that are valid for that index and datasource.
*/
public static function filterValidItemIds(IndexInterface $index, $datasource_id, array $item_ids) {
if (method_exists(ContentEntityTrackingManager::class, 'filterValidItemIds')) {
return ContentEntityTrackingManager::filterValidItemIds($index, $datasource_id, $item_ids);
}
else {
return ContentEntity::filterValidItemIds($index, $datasource_id, $item_ids);
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment