class MediaInternetOEmbedHandler in oEmbed 8
Same name and namespace in other branches
- 7 MediaInternetOEmbedHandler.inc \MediaInternetOEmbedHandler
- 7.0 MediaInternetOEmbedHandler.inc \MediaInternetOEmbedHandler
Implementation of MediaInternetBaseHandler.
Hierarchy
- class \MediaInternetOEmbedHandler extends \MediaInternetBaseHandler
Expanded class hierarchy of MediaInternetOEmbedHandler
See also
hook_media_internet_providers().
File
View source
class MediaInternetOEmbedHandler extends MediaInternetBaseHandler {
public $fileObject;
/**
* Claim this URL.
*/
public function claim($embedCode) {
$matches = array();
if (oembed_get_provider($embedCode, $matches)) {
return TRUE;
}
}
/**
* File should not validate if we cannot fetch valid oEmbed data.
*/
public function validate() {
$file = $this
->getFileObject();
$validators = array(
'oembed_file_validator_type' => array(),
);
$errors = file_validate($file, $validators);
foreach ($errors as $error) {
throw new MediaInternetValidationException($error);
}
}
/**
* Returns a file object which can be used for validation
*
* @return StdClass
*/
public function getFileObject() {
if (!$this->fileObject) {
$file = oembed_url_to_file($this->embedCode);
$this->fileObject = $file;
}
return $this->fileObject;
}
/**
* Returns an array representation of the oEmbed data, or NULL on failure.
*
* An example project that calls this method is Media Browser Plus
* (http://drupal.org/project/media_browser_plus). Other projects may do so
* in the future.
*/
public function getOEmbed() {
$embed = oembed_get_data($this->embedCode);
return $embed ? (array) $embed : NULL;
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
MediaInternetOEmbedHandler:: |
public | property | ||
MediaInternetOEmbedHandler:: |
public | function | Claim this URL. | |
MediaInternetOEmbedHandler:: |
public | function | Returns a file object which can be used for validation | |
MediaInternetOEmbedHandler:: |
public | function | Returns an array representation of the oEmbed data, or NULL on failure. | |
MediaInternetOEmbedHandler:: |
public | function | File should not validate if we cannot fetch valid oEmbed data. |