Skip to content

Conversation

@NathanPesneau
Copy link
Contributor

@NathanPesneau NathanPesneau commented Nov 20, 2025

Completes

Q A
Branch? 4.2
Tickets Closes #7478
License MIT
Doc PR tbd

This patch introduces a significant internal refactoring to how parameters are processed and applied to filters across API Platform's core, Doctrine, GraphQL, and Laravel integrations. The primary goal is to centralize and solidify parameter handling, particularly for filters that can operate on multiple properties using the :property placeholder.

Filters will now receive a more precise context. During the apply method, $context['filters'] will contain only the values directly relevant to the specific filter being processed. This simplifies filter implementation, and developers are encouraged to use $parameter->getValue() for direct access to their parameter's associated value.
The :property placeholder in parameter keys is now integrates with the getProperties() method of PropertyAwareFilterInterface implementations. This resolves previous inconsistencies and solidifies the behavior where :property placeholders are dynamically expanded and filled with the content of getProperties, ensuring a more predictable and consistent approach for filters that target multiple properties.

This is a risky change as it fundamentally alters how certain parameters, especially those using dynamic properties, are processed and how filters receive their values. The previous parameter handling, particularly concerning the interaction between getProperties on parameters and dynamic property expansion, was inconsistent and did not work properly in all scenarios. This patch solidifies that behavior.

use PHPUnit\Framework\Attributes\DataProvider;

/**
* @author Votre Nom <votre@email.com>
Copy link
Contributor

Choose a reason for hiding this comment

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

You need to replace it with your name and email

properties: ['description', 'name']
),
]
)]
Copy link
Member

Choose a reason for hiding this comment

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

$this->loadFixtures();
}

#[DataProvider('partialFilterParameterProvider')]
Copy link
Member

Choose a reason for hiding this comment

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

please add these tests to the DoctrineTest file

@soyuka soyuka force-pushed the fix-partial-exact-filter-property-placeholder branch 11 times, most recently from 8252ea7 to c109c09 Compare December 4, 2025 13:59
@soyuka soyuka marked this pull request as ready for review December 4, 2025 14:17
@soyuka soyuka changed the title Fix placeholder on exact and partial filters fix: consistent :property placeholder behavior Dec 4, 2025
@soyuka soyuka force-pushed the fix-partial-exact-filter-property-placeholder branch from c109c09 to a3313f5 Compare December 4, 2025 14:20
@soyuka soyuka merged commit 90f0d55 into api-platform:4.2 Dec 4, 2025
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.

3 participants