-
-
Notifications
You must be signed in to change notification settings - Fork 226
Refactor: properly handle callable array even when options are missing #1371
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
base: develop
Are you sure you want to change the base?
Refactor: properly handle callable array even when options are missing #1371
Conversation
Improved handling for cases where `$callable` is an array but does not include the `$callable['options']` key. In such cases, the default options are preserved and no errors occur. Also streamlined the normalization logic by explicitly checking for valid entries (`!empty()`)
|
@matteotrubini can you add some test cases for this? |
Expanded MarkupManagerTest to cover registration and validation of Twig functions, including handling of options, default options, empty callables, and invalid callables.
|
@LukeTowers, once I get your green light, I’ll proceed with makeTwigFilters() as described in the first comment. |
|
@matteotrubini ideally the options logic that's present everywhere in Winter could be centralized to a helper as much as possible. Should be good to proceed with the makeTwigFilters |
ed98069 to
4f88f25
Compare
39e3d0c to
21c9cbd
Compare
|
I have finished my review and the tests are green. I would squash the commits before marking the PR as ready - what do you think, @LukeTowers? |
|
@matteotrubini I always squash when merging, no need to worry about squashing on the PR itself. |
|
Is the intention behind this to allow definitions using October v4's syntax? (i.e. OFFLINE-GmbH/oc-responsive-images-plugin@741e145, https://github.com/octobercms/october/blob/8b8d2f7444ea98da488014504f51e12f4150465a/modules/system/classes/MarkupExtensionItem.php#L80-L98). If that's the case I think we need to be a bit more explicit about how we're supporting that to make sure that we're also properly parsing the options. |
|
The purpose of this PR is the one described in the first comment, and it was achieved with the initial commit. |
Improved handling for cases where
$callableis an array but does not include the$callable['options']key. In such cases, the default options are preserved and no errors occur.Also streamlined the normalization logic by explicitly checking for valid entries (
!empty())makeTwigFilters()function as well for consistency.Eventually, both implementations could be unified into a shared helper, as they follow the same logic.