mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
getParentIdNameRelation bug fixing and cleaning : This function is usefull only for the has_one and has_many relation but useless for many_many
Morerover, it manages well now the child heritage and parent heritage git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@53114 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
c5c3cf19b6
commit
eb018ad36a
@ -630,16 +630,13 @@ JS;
|
||||
/**
|
||||
* Returns the db-fieldname of the currently used relationship.
|
||||
*/
|
||||
function getParentIdNameRelation( $parentClass, $childClass, $relation ){
|
||||
function getParentIdNameRelation($parentClass, $childClass, $relation) {
|
||||
if($this->parentIdName) return $this->parentIdName;
|
||||
|
||||
$relations = singleton( $parentClass )->$relation();
|
||||
$classes = ClassInfo::ancestry( $childClass );
|
||||
foreach( $relations as $k => $v ) {
|
||||
if( $v == $childClass )
|
||||
return $k . 'ID';
|
||||
else if( array_key_exists( $v, $classes ) )
|
||||
return $classes[ $v ] . 'ID';
|
||||
$relations = singleton($parentClass)->$relation();
|
||||
$classes = ClassInfo::ancestry($childClass);
|
||||
foreach($relations as $k => $v) {
|
||||
if(array_key_exists($v, $classes)) return $k . 'ID';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user