From 999175d7419bb6a6c4cbdbe13d2be14df71b5aeb Mon Sep 17 00:00:00 2001 From: Mikael Nordfeldth Date: Sun, 25 Jan 2015 02:32:04 +0100 Subject: [PATCH] File_oembed::byFile to avoid littering with getKV --- plugins/Oembed/classes/File_oembed.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plugins/Oembed/classes/File_oembed.php b/plugins/Oembed/classes/File_oembed.php index cb8420e352..fda1636837 100644 --- a/plugins/Oembed/classes/File_oembed.php +++ b/plugins/Oembed/classes/File_oembed.php @@ -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; -- 2.39.5