Check if remote class exists in DataObject->getRemoteJoinField()

This commit is contained in:
Zauberfisch 2013-10-28 01:12:46 +00:00
parent 91e96ec1c0
commit 4b138cfe0b

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);
}