You are here

public static function video_utility::urlToUri in Video 7.2

Finds a stream wrapper using the output URL.

Examples of output URLs:

If no suitable stream wrapper is found, returns NULL.

@todo optimize: find the wrapperbase -> wrapper mapping just once.

1 call to video_utility::urlToUri()
TranscoderAbstractionFactoryZencoder::moveFile in transcoders/TranscoderAbstractionFactoryZencoder.inc

File

./video.utility.inc, line 63
This file will be used to keep all utility functions data structures.

Class

video_utility
Helper functions for the Video module.

Code

public static function urlToUri($url) {
  $uri = NULL;
  $mapping = self::getStreamBaseMapping();
  foreach ($mapping as $wrapperscheme => $wrapperbase) {
    $wrapperbaselength = drupal_strlen($wrapperbase);
    if (strncmp($wrapperbase, $url, $wrapperbaselength) === 0) {
      $uri = $wrapperscheme . '://' . drupal_substr($url, $wrapperbaselength);

      // Remove the query part
      if (($pos = strpos($uri, '?')) !== FALSE) {
        $uri = substr($uri, 0, $pos);
      }
      break;
    }
  }
  return $uri;
}