-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
[BREAKING] Fix empty param bag #82
base: main
Are you sure you want to change the base?
Conversation
this test demonstrates that scopes can be accessed in the transformers
if ($parentScope === 'author') { | ||
$data['called_by_author'] = 'indeed!'; | ||
} | ||
|
||
if ($parentScope === 'books') { | ||
$data['called_by_book'] = 'yes!'; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you can see, we are returnning different fields based on the context that we are in.
In the author
context we return, called_by_author
field, and
In the books
context we return, called_by_book
field.
It seems this is the reult that #39 wanted to achiev.
@@ -405,7 +405,7 @@ public function createData() | |||
$this->manager->parseFieldsets($this->fieldsets); | |||
} | |||
|
|||
return $this->manager->createData($this->getResource(), $this->resourceName); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the actual fix.
The rest are just tests 😬
Notes
This PR is based on Test nested includes #79 and utilizes the test classes introduced there. To make the review process smoother, it’s recommended that this PR be merged after Test nested includes #79.Summary
This PR addresses #49 and #62, both of which were caused by the changes introduced in #39.
The issue occurs when using the withResourceName method or setting the resource name in any other way, causing the include parameters to be empty. This problem is clearly described in #62.
More Context
In the use case described in #38, if the data returned by Country differs depending on the context (e.g., in the Portfolio context vs. other contexts), it indicates that a different or new transformer should be used for each context. This is precisely what transformers and includes are designed for: to return different data based on context.
If you need to return different data based on context, it is still possible to do so, as demonstrated in the test case.
resolve #49
resolve #62