From b83af83b82a9719e946504866058770b109ece71 Mon Sep 17 00:00:00 2001 From: Evan Prodromou Date: Fri, 26 Aug 2011 11:37:45 -0400 Subject: [PATCH] return links for foreign keys --- classes/Managed_DataObject.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/classes/Managed_DataObject.php b/classes/Managed_DataObject.php index 7263b3e320..552d980fba 100644 --- a/classes/Managed_DataObject.php +++ b/classes/Managed_DataObject.php @@ -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 -- 2.39.5