Some event subscribers do things which may not always be required.
For example, route creation: When we synchronize a document (and its referrers) from a different document manager we do not want the RouteSubscriber to create new routes when persisting the PageDocument - we just want it to do everything else.
I propose that this is solved by attributing a group/tag/context for each subscriber/listener and then only executing that listener when the context is given via. an option when persisting / finding etc.
For example, the RouteSubscriber could be activated only in a web context:
$dm->persist($document, null, ['context' => 'web']); // routes will be generated
$dm->persist($document, null, []); // routes will not be generated.
Alternatives
Add explicit options to disable generation (e.g. no_route_generate): Means coupling things to implementations.
Some event subscribers do things which may not always be required.
For example, route creation: When we synchronize a document (and its referrers) from a different document manager we do not want the
RouteSubscriber
to create new routes when persisting thePageDocument
- we just want it to do everything else.I propose that this is solved by attributing a group/tag/context for each subscriber/listener and then only executing that listener when the context is given via. an option when persisting / finding etc.
For example, the RouteSubscriber could be activated only in a
web
context:Alternatives
no_route_generate
): Means coupling things to implementations.