Skip to content
Snippets Groups Projects
Commit 819fc3d6 authored by Silvi Sanghavi's avatar Silvi Sanghavi Committed by Marcos Cano
Browse files

Issue #3260251 by dhruv.mittal, osman, alexpott, donquixote, marcoscano:...

Issue #3260251 by dhruv.mittal, osman, alexpott, donquixote, marcoscano: Error: Call to private method in entity_usage_form_alter()
parent aa6c643a
No related branches found
No related tags found
1 merge request!81Fixed error: Call to private method in entity_usage_form_alter().
Pipeline #423886 failed
......@@ -6,6 +6,7 @@
*/
use Drupal\Core\Cache\CacheableMetadata;
use Drupal\Core\Entity\EntityFormInterface;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Routing\RouteMatchInterface;
......@@ -85,7 +86,7 @@ function entity_usage_field_storage_config_delete(FieldStorageConfigInterface $f
*/
function entity_usage_form_alter(&$form, FormStateInterface $form_state, $form_id) {
$form_object = $form_state->getFormObject();
if (!method_exists($form_object, 'getEntity')) {
if (!$form_object instanceof EntityFormInterface) {
return;
}
/** @var \Drupal\Core\Entity\EntityInterface $entity */
......@@ -107,7 +108,7 @@ function entity_usage_form_alter(&$form, FormStateInterface $form_state, $form_i
if (!in_array($entity_type_id, $edit_entity_types) && !in_array($entity_type_id, $delete_entity_types)) {
return;
}
$is_edit_form = method_exists($form_object, 'getOperation') && $form_object->getOperation() === 'edit' && in_array($entity_type_id, $edit_entity_types);
$is_edit_form = $form_object->getOperation() === 'edit' && in_array($entity_type_id, $edit_entity_types);
$is_delete_form = FALSE;
if (!$is_edit_form && in_array($entity_type_id, $delete_entity_types)) {
// Even if this is not on the UI, sites can define additional form classes
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment