You are here

public function WebformCivicrmPostProcess::handleEntityTags in Webform CiviCRM Integration 8.5

Handle adding/updating tags for entities (cases, activity)

Parameters

$entityType:

$entityId:

$n:

$params:

2 calls to WebformCivicrmPostProcess::handleEntityTags()
WebformCivicrmPostProcess::processActivities in src/WebformCivicrmPostProcess.php
Save activity data
WebformCivicrmPostProcess::processCases in src/WebformCivicrmPostProcess.php
Save case data

File

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

Class

WebformCivicrmPostProcess

Namespace

Drupal\webform_civicrm

Code

public function handleEntityTags($entityType, $entityId, $n, $params) {
  foreach ($this->all_fields as $fid => $field) {
    list($set, $type) = explode('_', $fid, 2);
    if ($set == $entityType && isset($field['table']) && $field['table'] == 'tag') {
      $field_name = 'civicrm_' . $n . '_' . $entityType . '_1_' . $fid;
      if ((isset($params['tag']) || isset($this->enabled[$field_name])) && isset($this->data[$entityType][$n])) {
        $add = wf_crm_aval($this->data[$entityType][$n], $entityType . ":1:{$type}", []);
        $remove = $this
          ->getExposedOptions($field_name, $add);
        $this
          ->addOrRemoveMultivaluedData('tag', $entityType, $entityId, $add, $remove);
      }
    }
  }
}