Skip to content
Snippets Groups Projects

Fixed error: Call to private method in entity_usage_form_alter().

Merged Silvi Sanghavi requested to merge issue/entity_usage-3260251:8.x-2.x into 8.x-2.x
2 unresolved threads
+ 3
2
@@ -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
Loading