]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
return links for foreign keys
authorEvan Prodromou <evan@status.net>
Fri, 26 Aug 2011 15:37:45 +0000 (11:37 -0400)
committerEvan Prodromou <evan@status.net>
Fri, 26 Aug 2011 15:37:45 +0000 (11:37 -0400)
classes/Managed_DataObject.php

index 7263b3e3206f787c6116599f43f1a2e1e489c7aa..552d980fba172b362f4d06b67420cb411960d2bc 100644 (file)
@@ -152,4 +152,18 @@ abstract class Managed_DataObject extends Memcached_DataObject
 
         return $style;
     }
+
+    function links()
+    {
+        $links = array();
+
+        $table = call_user_func(array(get_class($this), 'schemaDef'));
+
+        foreach ($table['foreign keys'] as $keyname => $keydef) {
+            if (count($keydef) == 2 && is_string($keydef[0]) && is_array($keydef[1]) && count($keydef[1]) == 1) {
+                $links[$keydef[1][0]] = $keydef[0].':'.$keydef[1][1];
+            }
+        }
+        return $links;
+    }
 }
\ No newline at end of file