]> git.mxchange.org Git - quix0rs-gnu-social.git/blobdiff - classes/Profile.php
Make Profile::fromUri use UnknownUriException
[quix0rs-gnu-social.git] / classes / Profile.php
index 3f0b87e79fc550ebb68c6c31b3ba0608e5278930..961187bb93cb436135eac7159798f74914e5ecde 100644 (file)
@@ -1460,19 +1460,29 @@ class Profile extends Managed_DataObject
         return $feed;
     }
 
-    static function fromURI($uri)
+    /*
+     * Get a Profile object by URI. Will call external plugins for help
+     * using the event StartGetProfileFromURI.
+     *
+     * @param string $uri A unique identifier for a resource (profile/group/whatever)
+     */
+    static function fromUri($uri)
     {
         $profile = null;
 
         if (Event::handle('StartGetProfileFromURI', array($uri, &$profile))) {
-            // Get a local user
+            // Get a local user when plugin lookup (like OStatus) fails
             $user = User::getKV('uri', $uri);
-            if (!empty($user)) {
+            if ($user instanceof User) {
                 $profile = $user->getProfile();
             }
             Event::handle('EndGetProfileFromURI', array($uri, $profile));
         }
 
+        if (!$profile instanceof Profile) {
+            throw new UnknownUriException($uri);
+        }
+
         return $profile;
     }