private function WebformCivicrmPostProcess::processAttachments in Webform CiviCRM Integration 8.5
Parameters
string $ent - entity type:
int $n - entity number:
int $id - entity id:
bool $new - is this a new object? (should we bother checking for existing data):
2 calls to WebformCivicrmPostProcess::processAttachments()
- WebformCivicrmPostProcess::processActivities in src/
WebformCivicrmPostProcess.php - Save activity data
- WebformCivicrmPostProcess::processGrants in src/
WebformCivicrmPostProcess.php - Save grants
File
- src/
WebformCivicrmPostProcess.php, line 2364 - Front-end form validation and post-processing.
Class
Namespace
Drupal\webform_civicrmCode
private function processAttachments($ent, $n, $id, $new = FALSE) {
$attachments = $new ? [] : $this
->getAttachments($ent, $id);
foreach ((array) wf_crm_aval($this->data[$ent], "{$n}:{$ent}upload:1") as $num => $file_id) {
if ($file_id) {
list(, $i) = explode('_', $num);
$dao = new \CRM_Core_DAO_EntityFile();
if (!empty($attachments[$i])) {
$dao->id = $attachments[$i]['id'];
}
$dao->file_id = $file_id;
$dao->entity_id = $id;
$dao->entity_table = "civicrm_{$ent}";
$dao
->save();
}
}
}