Skip to content

Commit

Permalink
FIX: Allow join-object to be referenced as a component
Browse files Browse the repository at this point in the history
This avoids having arbitrary differences between a join object and a
has-one relation.
  • Loading branch information
Sam Minnee authored and chillu committed May 20, 2021
1 parent 6ba7bf7 commit c7c6bde
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/ORM/DataObject.php
Expand Up @@ -1844,6 +1844,11 @@ public function getComponent($componentName)
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';
Expand Down

0 comments on commit c7c6bde

Please sign in to comment.