public function getBundleFromInput($value, $check_access = TRUE, array $bundles = []) {
    // GovCMS Media overrides the media_bundle storage handler with a special
    // one that adds an optional second parameter to loadMultiple().
    $media_types = $this->entityTypeManager
      ->getStorage('media_type')
      ->loadMultiple($bundles ?: NULL, $check_access);
    ksort($media_types);

    /** @var \Drupal\media\MediaTypeInterface $media_type */
    foreach ($media_types as $media_type) {
      $source = $media_type->getSource();

      if ($source instanceof InputMatchInterface && $source->appliesTo($value, $media_type)) {
        return $media_type;
      }
    }
    throw new IndeterminateBundleException($value);
  }