silverstripe-crontask icon indicating copy to clipboard operation
silverstripe-crontask copied to clipboard

Use an Injector registry

Open sminnee opened this issue 9 years ago • 1 comments

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: [ "*" ]

sminnee avatar Aug 17 '15 21:08 sminnee

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.

robbieaverill avatar Dec 13 '17 05:12 robbieaverill