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);
  }
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);
  }
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 ) ; }
Returns the first media bundle that can accept an input value.

@param mixed $value
The input value.
@param bool $check_access
(optional) Whether to filter the bundles by create access for the current
user. Defaults to TRUE.
@param string[] $bundles
(optional) A set of media bundle IDs which might match the input. If
omitted, all available bundles are checked.

@return \Drupal\media\MediaTypeInterface
A media bundle that can accept the input value.

@throws \Drupal\govcms_media\Exception\IndeterminateBundleException
If no bundle can be matched to the input value.
Returns the first media bundle that can accept an input value .