class MediaInternetTestHandler in D7 Media 7.4
Same name and namespace in other branches
- 7.2 modules/media_internet/tests/includes/MediaInternetTestHandler.inc \MediaInternetTestHandler
- 7.3 modules/media_internet/tests/includes/MediaInternetTestHandler.inc \MediaInternetTestHandler
Implementation of MediaInternetBaseHandler.
Hierarchy
- class \MediaInternetBaseHandler
- class \MediaInternetTestHandler
Expanded class hierarchy of MediaInternetTestHandler
See also
hook_media_internet_providers().
File
- modules/
media_internet/ tests/ includes/ MediaInternetTestHandler.inc, line 13 - Extends the MediaInternetBaseHandler class to handle videos from an imaginary example.com.
View source
class MediaInternetTestHandler extends MediaInternetBaseHandler {
public function parse($embedCode) {
// http://example.com/video/*
$patterns = array(
'@example\\.com/video/(\\d+)@i',
);
foreach ($patterns as $pattern) {
preg_match($pattern, $embedCode, $matches);
if (isset($matches[1])) {
return file_stream_wrapper_uri_normalize('mediainternettest://video/' . $matches[1]);
}
}
}
public function claim($embedCode) {
if ($this
->parse($embedCode)) {
return TRUE;
}
}
public function getFileObject() {
$uri = $this
->parse($this->embedCode);
$file = file_uri_to_object($uri, TRUE);
// Override the default filename for testing purposes.
if (empty($file->fid)) {
$file->filename = 'Drupal';
}
return $file;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MediaInternetBaseHandler:: |
public | function | After the file has been saved, implementors may do additional operations. | 1 |
MediaInternetBaseHandler:: |
public | function | Before the file has been saved, implementors may do additional operations. | 1 |
MediaInternetBaseHandler:: |
public | function | Saves a file to the file_managed table (with file_save). | |
MediaInternetBaseHandler:: |
public | function | If required, implementors can validate the embedCode. | |
MediaInternetBaseHandler:: |
public | function | The constructor for the MediaInternetBaseHandler class. This method is also called from the classes that extend this class and override this method. | |
MediaInternetTestHandler:: |
public | function |
Determines if this handler should claim the item. Overrides MediaInternetBaseHandler:: |
|
MediaInternetTestHandler:: |
public | function |
Returns a file object which can be used for validation. Overrides MediaInternetBaseHandler:: |
|
MediaInternetTestHandler:: |
public | function |