Skip to content

Conversation

@tpatartmajeur
Copy link
Contributor

@tpatartmajeur tpatartmajeur commented Jul 17, 2025

This PR reorders the generated condition checks in the generate() method to prioritize the customCondition() check before other standard conditions.

In the generated mapper code, this change allows custom condition to occur earlier. As a result, potentially heavy methods, such as those that may trigger database queries are not executed if the custom condition fails.

Before:

if (isAllowedAttribute(...) && groupsCheck(...) && customCondition(...)) { // DB hit
   $result->someProperty = $value->someMethod(); // DB hit
}

After:

if (customCondition(...) && isAllowedAttribute(...) && groupsCheck(...)) {
    $result->someProperty = $value->someMethod(); // DB hit only if needed
}

Copy link
Member

@Korbeil Korbeil left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seems good to me.

Could you update the CHANGELOG to add a quick line about your change please ? 🙏

@tpatartmajeur tpatartmajeur force-pushed the custom-condition-priority branch from d833c84 to cd11637 Compare July 17, 2025 13:14
@tpatartmajeur
Copy link
Contributor Author

@Korbeil Done

@Korbeil Korbeil merged commit a109163 into jolicode:main Jul 17, 2025
6 checks passed
@Korbeil
Copy link
Member

Korbeil commented Jul 17, 2025

Thanks for your contribution @tpatartmajeur ! 🙏

@tpatartmajeur
Copy link
Contributor Author

Hi @Korbeil! Do you know when the next release is planned? We’re scheduling a production deployment soon, and having the changes from this MR included would be a great plus.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants