Created
May 28, 2013 04:19
-
-
Save jmertic/5660495 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getRelationshipByModules ($m1, $m2) | |
{ | |
global $db,$dictionary,$beanList; | |
$rel = new Relationship; | |
if($rel_info = $rel->retrieve_by_sides($m1, $m2, $db)){ | |
$bean = BeanFactory::getBean($m1); | |
$rel_name = $rel_info['relationship_name']; | |
foreach($bean->field_defs as $field=>$def){ | |
if(isset($def['relationship']) && $def['relationship']==$rel_name) { | |
return(array($def['name'], $m1)); | |
} | |
} | |
} elseif($rel_info = $rel->retrieve_by_sides($m2, $m1, $db)){ | |
$bean = BeanFactory::getBean($m2); | |
$rel_name = $rel_info['relationship_name']; | |
foreach($bean->field_defs as $field=>$def){ | |
if(isset($def['relationship']) && $def['relationship']==$rel_name) { | |
return(array($def['name'], $m2)); | |
} | |
} | |
} | |
return(FALSE); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment