sulu / sulu-document-manager

Sulu document manager
sulu.io
6 stars 7 forks source link

Event Subscriber Contexts. #76

Open dantleech opened 8 years ago

dantleech commented 8 years ago

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