You are here

private function WebformCivicrmPostProcess::verifyExistingContact in Webform CiviCRM Integration 8.5

Ensure we have a valid contact id in a contact ref field

Parameters

$cid:

$fid:

Return value

int

2 calls to WebformCivicrmPostProcess::verifyExistingContact()
WebformCivicrmPostProcess::getExistingContactIds in src/WebformCivicrmPostProcess.php
Fetch contact ids from "existing contact" fields
WebformCivicrmPostProcess::loadMultiPageData in src/WebformCivicrmPostProcess.php
Load entire webform submission during validation, including contact ids and $this->data Used when validation for one page needs access to submitted values from other pages

File

src/WebformCivicrmPostProcess.php, line 618
Front-end form validation and post-processing.

Class

WebformCivicrmPostProcess

Namespace

Drupal\webform_civicrm

Code

private function verifyExistingContact($cid, $fid) {
  $utils = \Drupal::service('webform_civicrm.utils');
  if ($utils
    ->wf_crm_is_positive($cid) && !empty($this->enabled[$fid])) {
    $contactComponent = \Drupal::service('webform_civicrm.contact_component');
    $component = $this->node
      ->getElement($fid);
    $filters = $contactComponent
      ->wf_crm_search_filters($this->node, $component);

    // Verify access to this contact
    if ($contactComponent
      ->wf_crm_contact_access($component, $filters, $cid) !== FALSE) {
      return $cid;
    }
  }
  return 0;
}