Quote from: Bogdan at Dec 07, 2008, 05:23 AM
Yes you are right, I have to distinguish between the different types of content that re replaced and this would be easy to handle. But another thought just came into my mind: all the events have to do something with "form" (OnBeforeDocFormSave, OnChunkFormSave, ...). After thinking about it I am not sure if I should trigger this events in the Doc Finder code at all as I am not handling with the form in any way but write the replaced content directly to the database.
The question is if this events are indeed closely related to the manager (form) or are also meant to be triggered when the database is directly manipulated. Maybe someone of the core developer team can help us with this question.
Even though the word "form" is in the name of the event, those are the only events available to trigger actions upon saving items. The triggers don’t have anything to do with the forms explicitly. They are just events that happen before and after saving. Usually that happens when using the forms (hence the name), but, as in the case of your module, the forms are not being used. I can’t see that it would cause any problems, since the events themselves don’t touch the forms.
However, you do have to make sure the right information is sent to the event. For example, the OnBeforeDocFormSave trigger is an array with two keys: ’mode’ and ’id’.
$modx->invokeEvent("OnBeforeDocFormSave", array (
"mode" => "upd",
"id" => $id
));
The OnBeforeModFormSave event also uses ’id’ as one of the keys:
$modx->invokeEvent("OnBeforeModFormSave",
array(
"mode" => "upd",
"id" => $id
));
... so of course you have make sure that your code doesn’t confuse the different kinds of ids. Depending on how your code is written, you might have to use different variables like $docId and $moduleId.