Call to undefined method Drupal\views_ui\Form\Ajax\ConfigHandlerExtra::getEntity() in Drupal\eca_content\Plugin\EntityReferenceSelection\EventBasedSelection->buildConfigurationForm()
Problem/Motivation
I'm not exactly sure what conditions trigger this issue, but it it appears that, while editing a view, and clicking "settings" on an exposed filter, \Drupal\eca_content\Plugin\EntityReferenceSelection\EventBasedSelection::buildConfigurationForm::buildConfigurationForm() can get a passed a form object of type \Drupal\views_ui\Form\Ajax\ConfigHandlerExtra, which doesn't have a getEntity() function, which results in a Error: Call to undefined method Drupal\views_ui\Form\Ajax\ConfigHandlerExtra::getEntity() in Drupal\eca_content\Plugin\EntityReferenceSelection\EventBasedSelection->buildConfigurationForm()
The problem is that the code in EventBasedSelection::buildConfigurationForm() assumes that the call to $form_state->getFormObject() will always return an EntityFormInterface...
public function buildConfigurationForm(array $form, FormStateInterface $form_state): array {
/** @var \Drupal\Core\Entity\EntityFormInterface $form_object */
$form_object = $form_state->getFormObject();
/** @var \Drupal\Core\Field\FieldDefinitionInterface $entity */
$entity = $form_object->getEntity();
// ...
}... but it appears that isn't always the case.
Interestingly, it appears that neither eca nor eca_content are used for this view. They're enabled and used for other views, just not the one that's throwing this error.
I ran across this issue while trying to determine why an exposed filter isn't limiting the list of available options to nodes of a certain type.
Steps to reproduce
(to be determined)
Proposed resolution
Only build the form if $form_object instanceof \Drupal\Core\Entity\EntityFormInterface
Remaining tasks
Write a patchReview and feedbackRTBC and feedbackCommit- Release
User interface changes
None.
API changes
None.
Data model changes
None.