You are here

private function WebformCivicrmPostProcess::expireRelationship in Webform CiviCRM Integration 8.5

End relationship for a pair of contacts

Parameters

$type:

$cid1:

$cid2:

1 call to WebformCivicrmPostProcess::expireRelationship()
WebformCivicrmPostProcess::saveRelationships in src/WebformCivicrmPostProcess.php
Save relationships for a contact

File

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

Class

WebformCivicrmPostProcess

Namespace

Drupal\webform_civicrm

Code

private function expireRelationship($removeTypes, $cid1, $cid2) {
  $utils = \Drupal::service('webform_civicrm.utils');
  foreach ($removeTypes as $type) {
    $existing = $this
      ->getRelationship([
      $type,
    ], $cid1, $cid2, TRUE);
    if (empty($existing['id'])) {
      continue;
    }
    $params = [
      'id' => $existing['id'],
      'end_date' => 'now',
      'is_active' => 0,
    ];
    $utils
      ->wf_civicrm_api('relationship', 'create', $params);
  }
}