Skip to content
Snippets Groups Projects

Issue #3482559: Error in JsonApiFacetsDeriver::getDerivativeDefinitions() if serverInstance is NULL

1 file
+ 3
1
Compare changes
  • Side-by-side
  • Inline
@@ -4,6 +4,7 @@ namespace Drupal\jsonapi_search_api_facets\Plugin\facets\facet_source;
use Drupal\Component\Plugin\PluginBase;
use Drupal\facets\FacetSource\FacetSourceDeriverBase;
use Drupal\search_api\ServerInterface;
/**
* Derives a facet source plugin definition for every index.
@@ -17,7 +18,8 @@ class JsonApiFacetsDeriver extends FacetSourceDeriverBase {
$derivatives = [];
foreach ($this->entityTypeManager->getStorage('search_api_index')->getQuery()->execute() as $index) {
// Only derive for an index that supports facets.
if ($this->entityTypeManager->getStorage('search_api_index')->load($index)->getServerInstance()->supportsFeature('search_api_facets')) {
$server = $this->entityTypeManager->getStorage('search_api_index')->load($index)->getServerInstance();
if ($server instanceof ServerInterface && $server->supportsFeature('search_api_facets')) {
$derivatives[$index] = [
'id' => $base_plugin_definition['id'] . PluginBase::DERIVATIVE_SEPARATOR . $index,
'display_id' => strtr('jsonapi_search_api_facets_!index', ['!index' => $index]),
Loading