Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POC Add new extension hook to update hasmany lists #10973

Closed
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/ORM/DataObject.php
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,10 @@ public function getComponents($componentName, $id = null)
$result = HasManyList::create($componentClass, $joinField);
}

// Guy note: This mirrors the "updateManyManyComponents" extension hook in getManyManyComponents()
// except it (by necessity) includes the component name as well.
$this->extend('updateComponents', $result, $componentName);

return $result
->setDataQueryParam($this->getInheritableQueryParams())
->forForeignID($id);
Expand Down Expand Up @@ -2111,9 +2115,11 @@ public function inferReciprocalComponent($remoteClass, $remoteRelation)
$joinField = "{$remoteRelation}ID";
$componentClass = $schema->classForField($remoteClass, $joinField);
$result = HasManyList::create($componentClass, $joinField);
return $result
$result = $result
->setDataQueryParam($this->getInheritableQueryParams())
->forForeignID($this->ID);
// $this->extend('updateComponents', $result, $componentName); // Not sure what the component name should be here though... maybe this isn't doable here?
return $result;
}
case 'belongs_to':
case 'has_many': {
Expand Down