You are here

public static function MarkerIconService::processSvgManagedFile in Geofield Map 8.2

React and further expands the managed_file element in case of SVG format.

Parameters

array $element: An associative array containing the properties and children of the element. Note that $element must be taken by reference here, so processed child elements are taken over into $form_state.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete form structure.

Return value

array The updated element.

File

src/Services/MarkerIconService.php, line 337

Class

MarkerIconService
Provides an Icon Managed File Service.

Namespace

Drupal\geofield_map\Services

Code

public static function processSvgManagedFile(array &$element, FormStateInterface $form_state, array &$complete_form) {
  $file_is_svg = FALSE;
  if (isset($element['fids']) && !empty($element['fids']['#value'])) {
    $fid = $element['fids']['#value'][0];
    $file_is_svg = ($file = $element['#files'][$fid]) && \Drupal::service('geofield_map.marker_icon')
      ->fileIsManageableSvg($file);
  }
  $element['is_svg'] = [
    '#type' => 'checkbox',
    '#value' => $file_is_svg,
    '#dafault_value' => $file_is_svg,
    '#attributes' => [
      'class' => [
        'visually-hidden',
      ],
    ],
  ];
  return $element;
}