Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.2.x will end 22 April 2024 (12 months).
  • Bug fixes for security issues in 4.2.x will end 7 October 2024 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.1.x is supported too.

Differences Between: [Versions 402 and 403]

(no description)

File Size: 264 lines (8 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

state_store:: (8 methods):
  __construct()
  delete()
  get()
  put()
  reset()
  wipe()
  get_state_ids()
  cleanup()


Class: state_store  - X-Ref

The state store manager.

__construct(string $component)   X-Ref
Constructor for a xAPI handler base class.

param: string $component the component name

delete(state $state)   X-Ref
Delete any extra state data stored in the database.

This method will be called only if the state is accepted by validate_state.

Plugins may override this method add extra clean up tasks to the deletion.

param: state $state
return: bool if the state is removed

get(state $state)   X-Ref
Get a state object from the database.

This method will be called only if the state is accepted by validate_state.

Plugins may override this method if they store some data in different tables.

param: state $state
return: state|null the state

put(state $state)   X-Ref
Inserts an state object into the database.

This method will be called only if the state is accepted by validate_state.

Plugins may override this method if they store some data in different tables.

param: state $state
return: bool if the state is inserted/updated

reset(?string $itemid = null,?int $userid = null,?string $stateid = null,?string $registration = null)   X-Ref
Reset all states from the component.
The given parameters are filters to decide the states to reset. If no parameters are defined, the only filter applied
will be the component.

Plugins may override this method if they store some data in different tables.

param: string|null $itemid
param: int|null $userid
param: string|null $stateid
param: string|null $registration

wipe(?string $itemid = null,?int $userid = null,?string $stateid = null,?string $registration = null)   X-Ref
Remove all states from the component
The given parameters are filters to decide the states to wipe. If no parameters are defined, the only filter applied
will be the component.

Plugins may override this method if they store some data in different tables.

param: string|null $itemid
param: int|null $userid
param: string|null $stateid
param: string|null $registration

get_state_ids(?string $itemid = null,?int $userid = null,?string $registration = null,?int $since = null,)   X-Ref
Get all state ids from a specific activity and agent.

Plugins may override this method if they store some data in different tables.

param: string|null $itemid
param: int|null $userid
param: string|null $registration
param: int|null $since filter ids updated since a specific timestamp
return: string[] the state ids values

cleanup()   X-Ref
Execute a state store clean up.

Plugins can override this methos to provide an alternative clean up logic.