File_oembed::byFile to avoid littering with getKV

This commit is contained in:
Mikael Nordfeldth 2015-01-25 02:32:04 +01:00
parent 97bf470895
commit 999175d741
1 changed files with 11 additions and 0 deletions

View File

@ -80,6 +80,17 @@ class File_oembed extends Managed_DataObject
}
}
/**
* Fetch an entry by using a File's id
*/
static function byFile(File $file) {
$file_oembed = self::getKV('file_id', $file->id);
if (!$file_oembed instanceof File_oembed) {
throw new ServerException(sprintf('No File_oembed entry for File id==%u', $file->id));
}
return $file_oembed;
}
public function getUrl()
{
return $this->url;