public static function video_utility::urlToUri in Video 7.2
Finds a stream wrapper using the output URL.
Examples of output URLs:
- http://bucket.s3.amazonaws.com/dir/file.ext output: s3://file.ext
- http://yoursite/sites/yoursite/files/dir/file.ext output: public://dir/file.ext
If no suitable stream wrapper is found, returns NULL.
@todo optimize: find the wrapperbase -> wrapper mapping just once.
1 call to video_utility::urlToUri()
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;
}