Commit ca4c9ccf authored by ChristianAdamski's avatar ChristianAdamski Committed by borisson_

Issue #2862982 by ChristianAdamski_: More defensive code when issueing the rest message.

parent 335f9198
......@@ -7,6 +7,8 @@ use Drupal\Core\Entity\EntityForm;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\facets\Plugin\facets\facet_source\SearchApiDisplay;
use Drupal\facets\FacetSource\SearchApiFacetSourceInterface;
use Drupal\search_api\Plugin\search_api\display\ViewsRest;
use Drupal\facets\Processor\ProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginManager;
use Drupal\facets\UrlProcessor\UrlProcessorInterface;
......@@ -578,9 +580,13 @@ class FacetForm extends EntityForm {
// Only widgets that return an array can work with rest facet sources, so if
// the user has selected another widget, we should point them to their
// misconfiguration.
if ($facet->getFacetSource()->getDisplay() instanceof \Drupal\search_api\Plugin\search_api\display\ViewsRest) {
if (strpos($values['widget'], 'array') === FALSE) {
$form_state->setErrorByName('widget', $this->t('The Facet source is a Rest export. Please select a raw widget.'));
if ($facet_source = $facet->getFacetSource()) {
if ($facet_source instanceof SearchApiFacetSourceInterface) {
if ($facet_source->getDisplay() instanceof ViewsRest) {
if (strpos($values['widget'], 'array') === FALSE) {
$form_state->setErrorByName('widget', $this->t('The Facet source is a Rest export. Please select a raw widget.'));
}
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment