You are here

function webform_content_creator_webform_submission_insert in Webform Content Creator 3.x

Same name and namespace in other branches
  1. 8 webform_content_creator.module \webform_content_creator_webform_submission_insert()
  2. 2.x webform_content_creator.module \webform_content_creator_webform_submission_insert()

Implements hook_webform_submission_insert().

File

./webform_content_creator.module, line 14
Allows to call functions after creating/editing/deleting webform submissions.

Code

function webform_content_creator_webform_submission_insert($webform_submission) {
  if (empty($webform_submission)) {
    return;
  }
  if (!$webform_submission
    ->isDraft()) {
    $entities = \Drupal::entityTypeManager()
      ->getStorage('webform_content_creator')
      ->loadMultiple();
    foreach ($entities as $e) {
      if (!$e
        ->equalsWebform($webform_submission
        ->bundle()) || !$e
        ->existsContentType()) {
        continue;
      }
      $e
        ->createNode($webform_submission);
    }
  }
}