Fixing phpstan errors - NCIOCPL/cgov-digital-platform GitHub Wiki
"Access to an undefined property Drupal\Core\Entity\EntityInterface::$field_application_module"
You have a hook function similar to:
/**
* Implements hook_entity_insert()
*/
function cgov_application_page_entity_insert(EntityInterface $entity) {
if ($entity->field_application_module->target_id === 'cgov_js_only_app') {
$cssUri = $entity->field_application_module->data['drupalConfig']['appCssUri'];
// Do something with the value.
}
}
Option A
Switch to hook_node_something
and replace EntityInterface
with Node
(e.g. hook_node_insert
).
- This needs to be a concrete type, not an interface (e.g.
Node
, notNodeInterface
) - 🚨 This assumes the hook in question can tolerate the use of Node; entity may have been used deliberately.