mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merged revisions 48633 via svnmerge from
svn://svn.silverstripe.com/silverstripe/modules/sapphire/branches/2.2.0-mesq ........ r48633 | ischommer | 2008-01-26 17:50:46 +1300 (Sat, 26 Jan 2008) | 1 line Allowing $many_many and $belongs_many_many for DataObjectDecorator (switching for direct statics to singleton($class)->stat()) ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@58308 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1a4212602f
commit
211aa73914
@ -1083,8 +1083,9 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
||||
if(in_array($class, array('ViewableData', 'Object', 'DataObject'))) continue;
|
||||
|
||||
if($component) {
|
||||
$manyMany = singleton($class)->stat('many_many');
|
||||
// Try many_many
|
||||
$candidate = eval("return isset({$class}::\$many_many[\$component]) ? {$class}::\$many_many[\$component] : null;");
|
||||
$candidate = (isset($manyMany[$component])) ? $manyMany[$component] : null;
|
||||
if($candidate) {
|
||||
$parentField = $class . "ID";
|
||||
$childField = ($class == $candidate) ? "ChildID" : $candidate . "ID";
|
||||
@ -1092,12 +1093,13 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
||||
}
|
||||
|
||||
// Try belongs_many_many
|
||||
$candidate = eval("return isset({$class}::\$belongs_many_many[\$component]) ? {$class}::\$belongs_many_many[\$component] : null;");
|
||||
$belongsManyMany = singleton($class)->stat('belongs_many_many');
|
||||
$candidate = (isset($belongsManyMany[$component])) ? $belongsManyMany[$component] : null;
|
||||
if($candidate) {
|
||||
$childField = $candidate . "ID";
|
||||
|
||||
// We need to find the inverse component name
|
||||
$otherManyMany = eval("return {$candidate}::\$many_many;");
|
||||
$otherManyMany = singleton($candidate)->stat('many_many');
|
||||
if(!$otherManyMany) {
|
||||
Debug::message("Inverse component of $candidate not found");
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user