How do I get the associated node from a webform entity?


I’m preprocessing a webform using hook_webform_submission_form_alter. The webform is being rendered as a node field. How can I, from inside my form_alter hook access that node?

function MY_MODULE_webform_submission_form_alter(array &$form, FormStateInterface $form_state, $form_id) {
    $parameters = Drupal::routeMatch()->getParameters();

    if ($parameters->has('node')) {

        // processing goes here

I’m fetching it from the url parameter right now, but I would prefer to do this in a cleaner way.

قالب وردپرس