Skip to content

Conversation

@matteotrubini
Copy link
Contributor

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())

⚠️ If this logic proves to be correct and stable, it should be applied to the makeTwigFilters() function as well for consistency.
Eventually, both implementations could be unified into a shared helper, as they follow the same logic.

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()`)
@LukeTowers
Copy link
Member

@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 LukeTowers self-requested a review June 24, 2025 14:53
@LukeTowers LukeTowers added the needs review Issues/PRs that require a review from a maintainer label Jun 24, 2025
@matteotrubini
Copy link
Contributor Author

@LukeTowers, once I get your green light, I’ll proceed with makeTwigFilters() as described in the first comment.

@LukeTowers
Copy link
Member

@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

@matteotrubini matteotrubini force-pushed the markupmanager-makeTwig-callable branch from ed98069 to 4f88f25 Compare July 13, 2025 11:42
@matteotrubini matteotrubini force-pushed the markupmanager-makeTwig-callable branch from 39e3d0c to 21c9cbd Compare July 13, 2025 14:05
@matteotrubini
Copy link
Contributor Author

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?

@LukeTowers
Copy link
Member

@matteotrubini I always squash when merging, no need to worry about squashing on the PR itself.

@LukeTowers LukeTowers marked this pull request as ready for review September 5, 2025 20:01
@LukeTowers
Copy link
Member

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.

@matteotrubini
Copy link
Contributor Author

The purpose of this PR is the one described in the first comment, and it was achieved with the initial commit.
Consequently, Offline.ResponsiveImages v2.9.0 has become functional.
The subsequent commits focus on unifying shared logic around the class.
All changes were made without access to the October v4 source code, and therefore without considering any change that may have been introduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs review Issues/PRs that require a review from a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants