mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merged revisions 53075 via svnmerge from
http://svn.silverstripe.com/open/modules/sapphire/branches/2.2.2 ........ r53075 | sminnee | 2008-04-21 10:56:46 +1200 (Mon, 21 Apr 2008) | 1 line Made has_one, has_many, and many_many methods more reliable ........ git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@53522 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1bc00f4b2d
commit
f427047b9d
@ -1002,16 +1002,10 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
||||
*/
|
||||
public function has_one($component = null) {
|
||||
$classes = ClassInfo::ancestry($this);
|
||||
$good = false;
|
||||
|
||||
foreach($classes as $class) {
|
||||
// Wait until after we reach DataObject
|
||||
if(!$good) {
|
||||
if($class == 'DataObject') {
|
||||
$good = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(in_array($class, array('Object', 'ViewableData', 'DataObject'))) continue;
|
||||
|
||||
if($component) {
|
||||
$candidate = eval("return isset({$class}::\$has_one[\$component]) ? {$class}::\$has_one[\$component] : null;");
|
||||
@ -1060,16 +1054,9 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
||||
*/
|
||||
public function has_many($component = null) {
|
||||
$classes = ClassInfo::ancestry($this);
|
||||
$good = false;
|
||||
|
||||
foreach($classes as $class) {
|
||||
// Wait until after we reach DataObject
|
||||
if(!$good) {
|
||||
if($class == 'DataObject') {
|
||||
$good = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if(in_array($class, array('ViewableData', 'Object', 'DataObject'))) continue;
|
||||
|
||||
if($component) {
|
||||
$candidate = eval("return isset({$class}::\$has_many[\$component]) ? {$class}::\$has_many[\$component] : null;");
|
||||
@ -1096,20 +1083,10 @@ class DataObject extends ViewableData implements DataObjectInterface {
|
||||
*/
|
||||
public function many_many($component = null) {
|
||||
$classes = ClassInfo::ancestry($this);
|
||||
$good = false;
|
||||
|
||||
foreach($classes as $class) {
|
||||
// Wait until after we reach DataObject
|
||||
if(!$good) {
|
||||
if($class == 'DataObject') {
|
||||
$good = true;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
if($class == 'DataObject' || $class == 'ViewableData') {
|
||||
continue;
|
||||
}
|
||||
if(in_array($class, array('ViewableData', 'Object', 'DataObject'))) continue;
|
||||
|
||||
if($component) {
|
||||
// Try many_many
|
||||
|
Loading…
Reference in New Issue
Block a user