public function MarkerIconService::getIconFileManagedElement in Geofield Map 8.2
Generate Icon File Managed Element.
Parameters
int $fid: The file to save.
int $row_id: The row id.
Return value
array The icon preview element.
File
- src/
Services/ MarkerIconService.php, line 295
Class
- MarkerIconService
- Provides an Icon Managed File Service.
Namespace
Drupal\geofield_map\ServicesCode
public function getIconFileManagedElement($fid, $row_id = NULL) {
$upload_location = $this
->markersLocationUri();
// Essentially we use the managed_file type, extended with some
// enhancements.
$element = $this->elementInfo
->getInfo('managed_file');
// Add custom and specific attributes.
$element['#row_id'] = $row_id;
$element['#geofield_map_marker_icon_upload'] = TRUE;
$element['#theme'] = 'image_widget';
$element['#preview_image_style'] = 'geofield_map_default_icon_style';
$element['#title'] = $this
->t('Choose a Marker Icon file');
$element['#title_display'] = 'invisible';
$element['#default_value'] = !empty($fid) ? [
$fid,
] : NULL;
$element['#error_no_message'] = FALSE;
$element['#upload_location'] = $upload_location;
$element['#upload_validators'] = $this->fileUploadValidators;
$element['#progress_message'] = $this
->t('Please wait...');
$element['#element_validate'] = [
[
get_class($this),
'validateIconImageStatus',
],
];
$element['#process'][] = [
get_class($this),
'processSvgManagedFile',
];
return $element;
}