fix(resource): Return full resource from resource/create getObject()#16894
fix(resource): Return full resource from resource/create getObject()#16894Ibochkarev wants to merge 1 commit intomodxcms:3.xfrom
Conversation
…ssor Resource\Create::cleanup() now returns $this->object instead of only ['id' => ...], so $response->getObject() contains all resource fields (pagetitle, description, content, etc.) as with element processors. Resolves modxcms#13912
Code ReviewSummary One-line change in Assessment Clean, minimal change. The Worth noting this is a behavioral change — any existing code that relies on Verdict: Approve — straightforward fix that improves API consistency. |
What does it do?
Resource\\Create::cleanup()now returns the full resource object ($this->object) instead of only['id' => $this->object->get('id')]. The response is still serialized bymodError::process()viatoArray(), so$response->getObject()returns all resource fields (pagetitle, description, content, etc.).Why is it needed?
After
resource/create, callers using$response->getObject()received only['id' => N]. Element create processors already return full or selected fields; resource create was inconsistent and broke code that expects the created resource data.How to test
$modx->runProcessor('resource/create', $fields)and then$response->getObject().id._build/test/Tests/Processors/Resource/ResourceCreateTest.phpto ensure existing resource creation tests still pass.Related issue(s)/PR(s)
Resolves #13912