Merge pull request #2616 from Zauberfisch/3.1

Check if remote class exists in DataObject->getRemoteJoinField()
This commit is contained in:
Ingo Schommer 2013-12-19 11:05:13 -08:00
commit 892b772d1c

View File

@ -1528,6 +1528,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
if(!$remoteClass) {
throw new Exception("Unknown $type component '$component' on class '$this->class'");
}
if(!ClassInfo::exists(strtok($remoteClass, '.'))) {
throw new Exception(
"Class '$remoteClass' not found, but used in $type component '$component' on class '$this->class'"
);
}
if($fieldPos = strpos($remoteClass, '.')) {
return substr($remoteClass, $fieldPos + 1) . 'ID';
@ -1546,8 +1551,9 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$message = "No has_one found on class '$remoteClass'";
if($type == 'has_many') {
// include a hint for missing has_many that is missing a has_one
$message .= ", the has_many relation from '$this->class' to '$remoteClass' requires a has_one on '$remoteClass'";
// include a hint for has_many that is missing a has_one
$message .= ", the has_many relation from '$this->class' to '$remoteClass'";
$message .= " requires a has_one on '$remoteClass'";
}
throw new Exception($message);
}