I am writing a patch for a module that used an old beta or even alpha of webform for drupal 8.
There is a line WebformEntityReferenceItem::getEntityWebformFieldName($node);
in the module that errors out saying getEntityWebformFieldName()
does not exist and sure enough in Drupal\webform\Plugin\Field\FieldType\WebformEntityReferenceItem
the method does not exist.
I checked an older release and the method was there at some point. I've been searching since yesterday but cannot find a workaround or even an answer as to why it was removed. Any ideas?
EDIT
So I managed to get it working, but this certainly seems like the incorrect way to do it.
$node->get('webform')->getValue()[0]['target_id'];
So it seems WebformEntityReferenceItem::getEntityWebformFieldName($node);
just gets the webform on the webform node and then grabs its 'target_id' value.
$webform_field_name = WebformEntityReferenceItem::getEntityWebformFieldName($node);
$webform_id = $node->$webform_field_name->target_id;
What I posted in my edit, I do not believe is the correct solution, albeit it is now working. Any suggestions would be appreciated.
WebformEntityReferenceItem::getEntityWebformFieldName();
doesn't appear to exist anymore as of webform 8-rc1. I want to know what to replace that with. I cannot find any mention of it being removed. The line in my edit seems to have fixed the module I am patching, but it seems hacky. – Ronnie Jan 9 '18 at 19:06