silverstripe-crontask
silverstripe-crontask copied to clipboard
Use an Injector registry
Right now, you need a separate class for each cronjob, and any class that exists will be automatically run. This is simpler, but also less flexible. For example, you can't create a class CronRunBuildTask
class that takes a build task as a wrapper.
That way, you could mix and match simple CronTask implementations with configured ones:
CronTaskController:
tasks:
- %$SyncHourlyTask
- %$Namesace\Class\I\Just\Want\To\Use\Without\Arguments
Injector:
SyncHourlyTask:
class: CronRunBuiskTask
properties:
Schedule: "* * * * 0"
BuildTask: FilesystemSyncTask
If you wanted to support the old way of running all implementors of the interface, you could have a config option for that:
CronTaskController:
tasks: [ "*" ]
This would let us move away from "magic" lookups towards explicit configuration, which would be in keeping with other parts of core. +1 from me.