public static function delete(array $element) {
    if ($element['#value']) {
      $file = File::load($element['#value']);
      $file->delete();

      // Clean up the file system if needed.
      $uri = $file->getFileUri();
      if (file_exists($uri)) {
        \Drupal::service('file_system')->unlink($uri);
      }
    }
  }
public static function delete(array $element) {
    if ($element['#value']) {
      $file = File::load($element['#value']);
      $file->delete();

      // Clean up the file system if needed.
      $uri = $file->getFileUri();
      if (file_exists($uri)) {
        \Drupal::service('file_system')->unlink($uri);
      }
    }
  }
public static function delete ( array $ element ) { if ( $ element [ '#value' ] ) { $ file = File :: load ( $ element [ '#value' ] ) ; $ file -> delete ( ) ; // Clean up the file system if needed. $ uri = $ file -> getFileUri ( ) ; if ( file_exists ( $ uri ) ) { \ Drupal :: service ( 'file_system' ) -> unlink ( $ uri ) ; } } }
Deletes the file referenced by the element.

@param array $element
The element. If set, its value should be a file entity ID.
Deletes the file referenced by the element .