function gdpr_tasks_collect_rta_data_extract_value in General Data Protection Regulation 7
Extract renderable text from entity property data.
1 call to gdpr_tasks_collect_rta_data_extract_value()
- gdpr_tasks_collect_rta_data in modules/
gdpr_tasks/ gdpr_tasks.module - Collect RTA data for a specific user.
File
- modules/
gdpr_tasks/ gdpr_tasks.module, line 527 - Module file for the GDPR Tasks module.
Code
function gdpr_tasks_collect_rta_data_extract_value($type, EntityMetadataWrapper $value, array &$assets) {
// If there is a callback, pass straight to that.
$info = $value
->info();
if (isset($info['gdpr sars callback']) && is_callable($info['gdpr sars callback'])) {
return $info['gdpr sars callback']($value, $assets);
}
// Dont try to render empty data.
$test_empty = $value
->value();
if (empty($test_empty)) {
return '';
}
// Make pre adjustment for known multi property values.
if ($type == 'field_item_image') {
$type = 'file';
$value = $value->file;
}
elseif ($type == 'text_formatted') {
$type = 'text';
$value = $value->value;
}
// Extract the value appropriately.
if ($type == 'entity') {
/* @var \EntityDrupalWrapper $value */
// @todo: Should we include filename to help people find it?
$label = $value
->label();
$id = $value
->getIdentifier();
return $label == $id ? $id : "{$value->label()} [{$value->getIdentifier()}]";
}
elseif ($type == 'file') {
/* @var \EntityDrupalWrapper $value */
$assets[] = array(
'fid' => $value
->getIdentifier(),
'display' => 1,
);
return "assets/{$value->getIdentifier()}." . pathinfo($value
->value()->uri, PATHINFO_EXTENSION);
}
else {
$raw_value = $value
->value();
return is_scalar($raw_value) ? (string) $raw_value : gettype($raw_value);
}
}