I have a plugin that does a bunch of stuff with external APIs onSaveEntry and then saves some of the gathered information back into the entry. I currently use craft()->entries->saveEntry($entry); but I obviously create a loop.

I saw this answer (Updating an entry after an event action within onSaveEntry) but since there is a nice detachEventHandler method I was wondering how to use it.

I tried hammering it with various combinations but I can't figure it out.

Right now, my plugin does this on init :

public function init(){
    craft()->on('entries.saveEntry', function(Event $event) {

Then rmsLinker, which is in my RmsLinkerService, checks if the entry comes from the right canal and if so calls another function who is also in the RmsLinkerService like so :

$this->sendShowToRmsV1($settings, $entryAttributes, $entry);

It's then in sendShowToRmsV1 that I need to do craft()->entries->saveEntry($entry) and prevent it from running the plugin all over again.

Any suggestions would be greatly appreciated.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.