Problem
PurgeHttpCacheListener (Symfony Doctrine and Laravel Eloquent) cannot invalidate sub-resource collection operations such as /parents/{parentId}/children. Resolving the IRI requires parent uriVariables that the listener does not have when it sees the modified entity, so those collection tags are silently skipped.
Pragmatic solution
Expose a public extension point — symmetric to Serializer\TagCollectorInterface on the response side — that the listener consults to collect extra tags for a given entity:
namespace ApiPlatform\HttpCache;
interface PurgeTagProviderInterface
{
/**
* @return iterable<string> additional cache tags to invalidate for $entity
*/
public function getTagsForResource(object $entity): iterable;
}
Wiring:
- Tagged service (Symfony) / iterator binding (Laravel), aggregated and injected into
PurgeHttpCacheListener.
- The listener appends whatever the providers yield to its existing tag set.
- Default ships with no provider — users opt in.
This keeps identifier-finding out of the framework (the user knows how their child invalidates their parents) and lets each project plug exactly the strategy that fits its routing (parent uri_variables, surrogate-key prefixes, class-based tags, etc.).
Scope
- Add the interface in
src/HttpCache/.
- Inject
iterable<PurgeTagProviderInterface> (optional, default empty) into both Symfony and Laravel PurgeHttpCacheListener.
- Document the seam alongside
TagCollectorInterface.
Problem
PurgeHttpCacheListener(Symfony Doctrine and Laravel Eloquent) cannot invalidate sub-resource collection operations such as/parents/{parentId}/children. Resolving the IRI requires parenturiVariablesthat the listener does not have when it sees the modified entity, so those collection tags are silently skipped.Pragmatic solution
Expose a public extension point — symmetric to
Serializer\TagCollectorInterfaceon the response side — that the listener consults to collect extra tags for a given entity:Wiring:
PurgeHttpCacheListener.This keeps identifier-finding out of the framework (the user knows how their child invalidates their parents) and lets each project plug exactly the strategy that fits its routing (parent uri_variables, surrogate-key prefixes, class-based tags, etc.).
Scope
src/HttpCache/.iterable<PurgeTagProviderInterface>(optional, default empty) into both Symfony and LaravelPurgeHttpCacheListener.TagCollectorInterface.