final class scheduled_service

internal  
 

High-level service for managing scheduled tasks.

This service centralizes all business logic related to scheduled tasks, and provides a clean API for modules, extensions and facades.

Methods

__construct(task_support $task_wrapper)

Constructor.

array
list()

List all scheduled tasks in the system.

get(string $classname)

Get a specific scheduled task.

bool
exists(string $classname)

Check if a task exists.

void
reset_component(string $component)

Reset scheduled tasks for a component to their defaults.

array
list_by_component(string $component)

List all scheduled tasks for a component only.

scheduled_task_dto|null
next(int $timestamp)

Get the next scheduled task that will run after a timestamp.

bool
is_overdue(scheduled_task_dto $task, int|null $now = null)

Determine if a scheduled task is overdue.

bool
is_customized(scheduled_task_dto $task)

Determine if a scheduled task is customized/overridden.

bool
run_now(string $classname)

Force run a scheduled task via CLI.

array
list_overdue(int|null $now = null)

List scheduled tasks that are overdue.

array
list_disabled()

List tasks that are disabled.

array
list_customized()

List tasks that were modified by config overrides.

Details

at line 39
__construct(task_support $task_wrapper)

Constructor.

Parameters

task_support $task_wrapper

at line 52
array list()

List all scheduled tasks in the system.

Return Value

array

at line 62
scheduled_task_dto get(string $classname)

Get a specific scheduled task.

Parameters

string $classname

Return Value

scheduled_task_dto

Exceptions

moodle_exception

at line 76
bool exists(string $classname)

Check if a task exists.

Parameters

string $classname

Return Value

bool

at line 90
void reset_component(string $component)

Reset scheduled tasks for a component to their defaults.

This is useful when deploying new versions of plugins that modify db/tasks.php.

Parameters

string $component

Return Value

void

at line 100
array list_by_component(string $component)

List all scheduled tasks for a component only.

Parameters

string $component

Return Value

array

at line 115
scheduled_task_dto|null next(int $timestamp)

Get the next scheduled task that will run after a timestamp.

Parameters

int $timestamp

Return Value

scheduled_task_dto|null

at line 123
bool is_overdue(scheduled_task_dto $task, int|null $now = null)

Determine if a scheduled task is overdue.

Parameters

scheduled_task_dto $task
int|null $now

Return Value

bool

at line 133
bool is_customized(scheduled_task_dto $task)

Determine if a scheduled task is customized/overridden.

Parameters

scheduled_task_dto $task

Return Value

bool

at line 143
bool run_now(string $classname)

Force run a scheduled task via CLI.

Useful for admin screens or automation panels.

Parameters

string $classname

Return Value

bool

at line 164
array list_overdue(int|null $now = null)

List scheduled tasks that are overdue.

Parameters

int|null $now

Return Value

array

at line 179
array list_disabled()

List tasks that are disabled.

Return Value

array

at line 192
array list_customized()

List tasks that were modified by config overrides.

Return Value

array