You are here

function media_internet_get_provider in D7 Media 7.3

Same name and namespace in other branches
  1. 7.4 modules/media_internet/media_internet.module \media_internet_get_provider()
  2. 7 modules/media_internet/media_internet.module \media_internet_get_provider()
  3. 7.2 modules/media_internet/media_internet.module \media_internet_get_provider()

Finds the appropriate provider for a given URL or embed_string

Each provider has a claim() method which it uses to tell media_internet that it should handle this input. We cycle through all providers to find the right one.

@todo: Make this into a normal hook or something because we have to instantiate each class to test and that's not right.

2 calls to media_internet_get_provider()
media_internet_add_submit in modules/media_internet/media_internet.module
Upload a file from a URL.
media_internet_add_validate in modules/media_internet/media_internet.module
Allow stream wrappers to have their chance at validation.

File

modules/media_internet/media_internet.module, line 112

Code

function media_internet_get_provider($embed_string) {
  foreach (media_internet_get_providers() as $class_name => $nothing) {
    module_load_include('inc', $nothing['module'], 'includes/' . $class_name);
    $p = new $class_name($embed_string);
    if ($p
      ->claim($embed_string)) {
      return $p;
    }
  }
  throw new MediaInternetNoHandlerException(t('Unable to handle the provided embed string or URL.'));
}