diff --git a/rabbit_hole.module b/rabbit_hole.module index 22caaf0..0295448 100644 --- a/rabbit_hole.module +++ b/rabbit_hole.module @@ -7,6 +7,7 @@ use Drupal\Core\Routing\RouteMatchInterface; use Drupal\Core\Form\FormStateInterface; +use Drupal\Core\Entity\EntityFormInterface; /** * Implements hook_help(). @@ -56,7 +57,7 @@ function rabbit_hole_form_alter(&$form, FormStateInterface $form_state, $form_id ->loadSupportedBundleEntityTypes(); $affected_global_forms = \Drupal::service('plugin.manager.rabbit_hole_entity_plugin') ->loadSupportedGlobalForms(); - if (method_exists($form_state->getFormObject(), 'getEntity')) { + if ($form_state->getFormObject() instanceof EntityFormInterface) { $current_type = $form_state->getFormObject()->getEntity()->getEntityTypeId(); $current_operation = $form_state->getFormObject()->getOperation(); $disallowed_operations = ['delete', 'cancel'];