Panel hooks from loop fails

haha. it always helps writing to the forum. explaining a problem is half way of solving it.

i just added a static ‘lock’ to my own class blocking the main function to be called nested.

private static $lock;
public function main() {
  if(MyClass::$lock) return;
  MyClass::$lock = true;
  
  try {
     // do work
  } catch(Exception $ex) {
    // maybe echo ex
  }
  finally {
      MyClass::$lock = false;
  }
}
3 Likes