Open Adrienb91 opened 5 years ago
@Adrienb91 it's a great suggestion, I am a bit worried about this being a breaking change. If you want to work on it and send me a PR I'll be more than happy to review it, if you do that just make sure not to introduce breaking changes
Hello,
I'm using your good cron php manager, connected to my database. I want to log my cron executions to do a dashboard of all cronjobs and be able to manage the tasks in an dedicated interface with last execution result.
To store the result of a cron job I have to use your then() function but (perhaps as the issue 51) I've a problem with passing arguments to the then() function.
I've made some changes to your Job.php file to do that :
In Job.php
Juste after the line private $after; add : /**
Add argument $args to then() declaration function to be : public function then(callable $fn, array $args, $runInBackground = false)
In then function, after $this->after = $fn; add : $this->afterArgs = $args;
In finalize function change : call_user_func($this->after, $this->output, $this->returnCode); by : call_user_func_array($this->after, array($this->afterArgs, $this->output, $this->returnCode));
It's done ! We can now call then function like then($afterExecutionFunction,array($arg1,$arg2)); And use this arguments from array in the function like : $afterExecutionFunction=function($args, $output) { print_r($args); $arg1=$args[0]; $arg2=$args[1];
Do you think it's a good way to solve the problem ?
Thanks for this good php cron manager and hope this can interest somebody.