1

I couldn't find a event that is triggered after clearing the cache. Is there one that I didn't see or is there another way to execute a controller action after the cache is cleared? It only concerns the data cache.

Thanks in advance!

1 Answer 1

1

I found the event after a more thorough search. Every controller has the EVENT_AFTER_ACTION event, which is triggered after each action. The triggering action can be found with the id attribute on the event.

Event::on(
  UtilitiesController::class, 
  Controller::EVENT_AFTER_ACTION, 
  function (ActionEvent $event) {
    if ($event->action->id == 'clear-caches-perform-action') {
      //do your stuff
    }
  }
);

I didn't find a way to only listen to the clearing of the data cache. Feel free to add to my answer if you should know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.