I have three content types (A,B,C). A and B have title, author, and field_version (a custom field), while C doesn't have field_version. Let's assume I have a method that gets the version value from a node. (The $node
parameter is an entity object.)
function getLatestVersion($node) {
$version = $node->get('field_version'); //for A, B is OK, but for C - field_version is unknown
}
How can I check the field exists for the node passed as argument without comparing the node type with an hard-coded list?
if (!empty($node->get('field_version'))) { $version = $no...