Skip to content

Conversation

@GromNaN
Copy link
Contributor

@GromNaN GromNaN commented Sep 16, 2025

Q A
Branch? 4.2
Tickets -
License MIT
Doc PR -

The filter context is passed by reference to each filter instance. In order to let the filters update any key in the context to be accessible in other filter calls, I propose a more generic copy of values.

Only the filters and parameter keys are specific to the current filter call.

I don't know how and where to test it.

@soyuka
Copy link
Member

soyuka commented Sep 17, 2025

We can test this inside src/Doctrine/Odm/Tests/Extension/ there are instructions on how to run a test for a specific component inside CONTRIBUTING.md

@GromNaN GromNaN force-pushed the mongodb-parameters-context branch from 1a624f4 to 59c6ace Compare September 17, 2025 09:54
@GromNaN GromNaN marked this pull request as draft September 17, 2025 09:54
@GromNaN GromNaN force-pushed the mongodb-parameters-context branch from 59c6ace to 22d1bc3 Compare September 17, 2025 10:46
@GromNaN GromNaN force-pushed the mongodb-parameters-context branch from 22d1bc3 to a13be92 Compare September 17, 2025 11:23
@GromNaN GromNaN marked this pull request as ready for review September 17, 2025 11:24
Comment on lines 92 to 97
$context['filters'] = $values;
$context['parameter'] = $parameter;

$filter->apply($aggregationBuilder, $resourceClass, $operation, $context);

unset($context['filters'], $context['parameter']);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed the implementation to be more straightforward: setting and unsetting fields from the $context array.

Copy link
Member

Choose a reason for hiding this comment

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

clever thanks this is great

@soyuka soyuka force-pushed the mongodb-parameters-context branch from 5ef27de to 83f8f8c Compare September 18, 2025 09:28
@soyuka soyuka merged commit d921dd3 into api-platform:4.2 Sep 18, 2025
111 of 112 checks passed
@GromNaN GromNaN deleted the mongodb-parameters-context branch September 18, 2025 12:08
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