Moodle APIs  3.8
Moodle 3.8.6 (Build: 20201109)
Public Member Functions | Public Attributes | Protected Member Functions | Protected Attributes | List of all members
setting_dependency Class Reference

Generic abstract dependency class. More...

Inheritance diagram for setting_dependency:
setting_dependency_disabledif_equals setting_dependency_disabledif_checked setting_dependency_disabledif_empty setting_dependency_disabledif_in_array setting_dependency_disabledif_not_checked setting_dependency_disabledif_not_empty setting_dependency_disabledif_not_equals setting_dependency_disabledif_equals2

Public Member Functions

 __construct (base_setting $setting, base_setting $dependentsetting, $defaultvalue=false)
 Creates the dependency object. More...
 
 destroy ()
 Destroy all circular references. More...
 
 enforce ()
 This function enforces the dependency.
 
 get_dependent_setting ()
 Gets the dependent setting. More...
 
 get_moodleform_properties ()
 Returns an array of properties suitable to be used to define a moodleforms disabled command. More...
 
 get_setting ()
 Gets the primary setting. More...
 
 is_locked ()
 Returns true if the dependent setting is locked by this setting_dependency. More...
 
 process_change ($changetype, $oldvalue)
 Processes a change is setting called by the primary setting. More...
 

Public Attributes

const DISABLED_CHECKED = 4
 
const DISABLED_EMPTY = 6
 
const DISABLED_FALSE = 3
 
const DISABLED_NOT_CHECKED = 5
 
const DISABLED_NOT_EMPTY = 7
 
const DISABLED_NOT_VALUE = 1
 
const DISABLED_TRUE = 2
 
const DISABLED_VALUE = 0
 Used to define the type of a dependency. More...
 

Protected Member Functions

 process_status_change ($oldstatus)
 All dependencies must define how they would like to deal with a status change. More...
 
 process_value_change ($oldvalue)
 All dependencies must define how they would like to process a value change.
 
 process_visibility_change ($oldvisibility)
 Processes a visibility change. More...
 

Protected Attributes

mixed $defaultvalue
 The default setting.
 
base_setting $dependentsetting
 The dependent setting (secondary)
 
mixed $lastvalue
 The last value the dependent setting had.
 
base_setting $setting
 The parent setting (primary)
 

Detailed Description

Generic abstract dependency class.

License
http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later

Constructor & Destructor Documentation

◆ __construct()

setting_dependency::__construct ( base_setting  $setting,
base_setting  $dependentsetting,
  $defaultvalue = false 
)

Creates the dependency object.

Parameters
base_setting$settingThe parent setting or the primary setting if you prefer
base_setting$dependentsettingThe dependent setting
mixed$defaultvalueThe default value to assign if the dependency is unmet

Reimplemented in setting_dependency_disabledif_empty, setting_dependency_disabledif_not_empty, setting_dependency_disabledif_not_checked, and setting_dependency_disabledif_checked.

Member Function Documentation

◆ destroy()

setting_dependency::destroy ( )

Destroy all circular references.

It helps PHP 5.2 a lot!

◆ get_dependent_setting()

setting_dependency::get_dependent_setting ( )

Gets the dependent setting.

Return values
backup_setting

◆ get_moodleform_properties()

setting_dependency::get_moodleform_properties ( )
abstract

◆ get_setting()

setting_dependency::get_setting ( )

Gets the primary setting.

Return values
backup_setting

◆ is_locked()

setting_dependency::is_locked ( )
abstract

Returns true if the dependent setting is locked by this setting_dependency.

Return values
bool

Reimplemented in setting_dependency_disabledif_equals.

◆ process_change()

setting_dependency::process_change (   $changetype,
  $oldvalue 
)
final

Processes a change is setting called by the primary setting.

Parameters
int$changetype
mixed$oldvalue
Return values
bool

◆ process_status_change()

setting_dependency::process_status_change (   $oldstatus)
abstractprotected

All dependencies must define how they would like to deal with a status change.

Parameters
int$oldstatus

Reimplemented in setting_dependency_disabledif_equals.

◆ process_visibility_change()

setting_dependency::process_visibility_change (   $oldvisibility)
protected

Processes a visibility change.

Parameters
bool$oldvisibility
Return values
bool

Member Data Documentation

◆ DISABLED_VALUE

const setting_dependency::DISABLED_VALUE = 0

Used to define the type of a dependency.

Note with these that checked and true, and not checked and false are equal. This is because the terminology differs but the resulting action is the same. Reduces code!


The documentation for this class was generated from the following file: