mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Check if remote class exists in DataObject->getRemoteJoinField()
This commit is contained in:
parent
91e96ec1c0
commit
4b138cfe0b
@ -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);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user