function WebformCivicrmBase::getFileInfo in Webform CiviCRM Integration 8.5
Retrieve info needed for pre-filling a webform file field
Parameters
string $fieldName:
string|int $val: url or civi file id:
string|null $entity: entity name:
int|null $n: entity id:
Return value
array|null
2 calls to WebformCivicrmBase::getFileInfo()
- WebformAjax::contactAjax in src/
WebformAjax.php - Load one or more contacts via ajax
- WebformCivicrmPreProcess::fillForm in src/
WebformCivicrmPreProcess.php - Recursively walk through form array and set properties of CiviCRM fields
File
- src/
WebformCivicrmBase.php, line 796 - Front-end form handler base class.
Class
- WebformCivicrmBase
- Class WebformCivicrmBase
Namespace
Drupal\webform_civicrmCode
function getFileInfo($fieldName, $val, $entity, $n) {
if (!$val) {
return NULL;
}
if ($fieldName === 'image_URL') {
return [
'data_type' => 'File',
'name' => NULL,
'icon' => $val,
];
}
$file = \Drupal::service('webform_civicrm.utils')
->wf_crm_apivalues('Attachment', 'get', $val);
if (!empty($file[$val])) {
return [
'data_type' => 'File',
'name' => $file[$val]['name'],
'file_url' => $file[$val]['url'],
'icon' => file_icon_class($file[$val]['mime_type']),
];
}
return NULL;
}