Exit gracefully from Editor's PHP preRemove function

Exit gracefully from Editor's PHP preRemove function

richardvkrichardvk Posts: 13Questions: 7Answers: 0

Hi,

I am using PHP libraries for Editor. I am using the 'on preRemove' function to run some checks before the delete (remove) actually occurs, and in some cases i want to exit back to the caller gracefully WITHOUT actually performing the delete.

Is this possible?

Richard

This question has an accepted answers - jump to answer

Answers

  • allanallan Posts: 61,821Questions: 1Answers: 10,126 Site admin
    Answer ✓

    Hi Richard,

    At the moment the events are just notifications of what is going to happen, or what has happened. There is no way to prevent the execution of the delete from the preRemove callback at this time (although that is a sensible idea and I've added it to my list).

    At the moment you would need to check if you want the delete to happen before you call the Editor->process() method.

    if ( Editor::action( $_POST ) === Editor::ACTION_DELETE ) ) {
      ... logic check
    }
    

    Allan

  • richardvkrichardvk Posts: 13Questions: 7Answers: 0

    Thanks Allan, I thought that might be the case :) I will go ahead and try your suggestion which is similar to what i was testing already.

    Thanks for adding to your list, i think it would be a useful option :)

    -R

This discussion has been closed.