Looking at getCallback() and resolveCallback(), the cron job entity's callback property can be any of:

- a PHP callable such as a function name, or a method on a class
- Controller in the service:method notation
- Controller in the class::method notation

This needs to be documented:

- on the CronJob::$callback property
- in the config schema
- in the README (which seems really out of date anyway, so would need a total rewrite as part of a more general issue)

Comments

joachim created an issue.

ericpoir’s picture

Today I had to use callbacks which I created in a service class and it works exactly how you described it.

I had to look up the resolveCallback() method to better understand how it works but here's an example of how I implemented the service callback in my .yml file:

callback: service_name:method

Was pretty simple to implement. The only place where I was facing some difficulties is when I was trying to update the cron job that I already imported to my drupal website. I had to go through some loops of drush cex, drush deploy and clearing the cache from the UI also helped not making my cron job page crash. That last part is mostly due to my Docker setup but putting it out there in case someone else is facing the same issues.