From 211aa73914fdfba25898cdca9f7123433029204a Mon Sep 17 00:00:00 2001 From: Ingo Schommer Date: Thu, 17 Jul 2008 22:06:34 +0000 Subject: [PATCH] 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 --- core/model/DataObject.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/model/DataObject.php b/core/model/DataObject.php index beb19c15b..ef23abc76 100644 --- a/core/model/DataObject.php +++ b/core/model/DataObject.php @@ -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"); }