FIX: Allow join-object to be referenced as a component

This avoids having arbitrary differences between a join object and a
has-one relation.
This commit is contained in:
Sam Minnee 2019-08-26 12:25:00 +12:00 committed by Ingo Schommer
parent 6ba7bf7b2f
commit c7c6bdebdf
1 changed files with 5 additions and 0 deletions

View File

@ -1844,6 +1844,11 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
return $this->components[$componentName];
}
// The join object can be returned as a component, named for its alias
if (isset($this->record[$componentName]) && $this->record[$componentName] === $this->joinRecord) {
return $this->record[$componentName];
}
$schema = static::getSchema();
if ($class = $schema->hasOneComponent(static::class, $componentName)) {
$joinField = $componentName . 'ID';