]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
File_oembed::byFile to avoid littering with getKV
authorMikael Nordfeldth <mmn@hethane.se>
Sun, 25 Jan 2015 01:32:04 +0000 (02:32 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Sun, 25 Jan 2015 01:32:04 +0000 (02:32 +0100)
plugins/Oembed/classes/File_oembed.php

index cb8420e352c6bc297335f9d3481e95d7683fddf9..fda16368376257e57d0ad75b20ea51e4b48c3cdf 100644 (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;