Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
backup_optigroup_element Class Reference

Instantiable class representing one optigroup element for conditional branching. More...

Inheritance diagram for backup_optigroup_element:
backup_nested_element base_nested_element processable base_final_element base_atom

Public Member Functions

 __construct ($name, $final_elements=null, $conditionparam=null, $conditionvalue=null)
 Constructor - instantiates one backup_optigroup_element.
 
 add_add_optigroup ($optigroup)
 Adding optigroups is forbidden.
 
 add_attributes ($attributes)
 Adding attributes is forbidden.
 
 add_child ($element)
 
 add_final_elements ($final_elements)
 
 add_optigroup ($optigroup)
 
 annotate_files ($component, $filearea, $elementname, $filesctxid=null)
 
 annotate_ids ($itemname, $elementname)
 
 clean_value ()
 
 clean_values ()
 
 condition_matches ()
 Evaluate the condition, returning if matches (true) or no (false)
 
 destroy ()
 Destroy all circular references.
 
 fill_values ($values)
 Simple filler that, matching by name, will fill both attributes and final elements depending of this nested element, debugging info about non-matching elements and/or elements present in both places.
 
 get_attribute ($name)
 
 get_attributes ()
 Public API starts here.
 
 get_child ($name)
 
 get_children ()
 
 get_condition_param ()
 
 get_condition_value ()
 
 get_counter ()
 
 get_file_annotations ()
 Returns one array containing the element in the @backup_structure and the areas to be searched.
 
 get_final_element ($name)
 
 get_final_elements ()
 Public API starts here.
 
 get_level ()
 Return the level of this element, that will be, the level of the parent (doesn't consume level) (note this os only a "cosmetic" effect (to_string) as fact as the real responsible for this is the corresponding structure_processor for the final output.
 
 get_logs ()
 Returns the logs.
 
 get_name ()
 Public API starts here.
 
 get_optigroup ()
 
 get_parent ()
 
 get_results ()
 Returns the results.
 
 get_source_array ()
 
 get_source_sql ()
 
 get_source_table ()
 
 get_source_table_sortby ()
 
 get_value ()
 
 is_set ()
 
 process ($processor)
 process one optigroup_element
 
 set_condition ($conditionparam, $conditionvalue)
 Sets the condition for this optigroup.
 
 set_source_alias ($dbname, $finalelementname)
 
 set_source_array ($arr)
 
 set_source_sql ($sql, $params)
 
 set_source_table ($table, $params, $sortby=null)
 
 set_value ($value)
 
 to_string ($showvalue=false)
 

Protected Member Functions

 add_log ($message, $level, $a=null, $depth=null, $display=false)
 Saves a log message to an array.
 
 add_result ($result)
 Saves the results to an array.
 
 add_used ($element)
 
 check_and_set_used ($element)
 
 convert_sql_params ($params)
 
 convert_table_params ($params)
 
 find_element ($param)
 
 find_element_by_path ($path)
 
 find_first_parent_by_name ($name)
 
 get_grandoptigroupelement_or_grandparent ()
 
 get_grandparent ()
 
 get_iterator ($processor)
 Returns one PHP iterator over each "ocurrence" of this nested element (array or DB recordset).
 
 get_new_attribute ($name)
 Instantiating attributes is forbidden.
 
 get_new_final_element ($name)
 Returns one instace of the @final_element class to work with when final_elements are added simply by name.
 
 get_used ()
 
 set_parent ($element)
 Set the parent of the optigroup_element and, at the same time, process the condition param.
 
 set_used ($used)
 
 validate_name ($name)
 

Protected Attributes

array $aliases
 
int $counter
 
array $fileannotations
 
stdClass[] $logs
 
mixed $params
 
array $procparams
 
array $results
 
string $sql
 
string $table
 
string $tablesortby
 
array $var_array
 To be used in case we pass one in-memory structure.
 

Detailed Description

Instantiable class representing one optigroup element for conditional branching.

Objects of this class are internally nested elements, so they support having both final elements and children (more nested elements) and are able to have one source and all the stuff supported by nested elements. Their main differences are:

  • Support for conditional execution, using simple equality checks with outer values.
  • Don't have representation in the hierarchy, so:
    • Their level is the level of the parent of their enclosing optigroup.
    • Act as one "path bridge" when looking for parent path values
    • They don't support attributes

Their main use is to allow conditional branching, basically for optional submodules like question types, assignment subtypes... where different subtrees of information must be exported. It's correct to assume that each submodule will define its own optigroup_element for backup purposes.

Constructor & Destructor Documentation

◆ __construct()

backup_optigroup_element::__construct ( $name,
$final_elements = null,
$conditionparam = null,
$conditionvalue = null )

Constructor - instantiates one backup_optigroup_element.

Parameters
string$nameof the element
array$final_elementsthis element will handle (optional, defaults to null)
string$condition_paramparam (path) we are using as source for comparing (optional, defaults to null)
string$condition_valuevalue we are comparing to (optional, defaults to null)

Member Function Documentation

◆ add_attributes()

backup_optigroup_element::add_attributes ( $attributes)

Adding attributes is forbidden.

Reimplemented from base_final_element.

◆ add_final_elements()

base_nested_element::add_final_elements ( $final_elements)
inherited

Reimplemented in base_optigroup.

◆ add_log()

backup_nested_element::add_log ( $message,
$level,
$a = null,
$depth = null,
$display = false )
protectedinherited

Saves a log message to an array.

See also
backup_helper\log()
Parameters
string$messageto add to the logs
int$levellevel of importance backup::LOG_DEBUG and other constants
mixed$ato be included in $message
int$depthof the message
display$boolsupporting translation via get_string() if true
Return values
void

◆ add_result()

backup_nested_element::add_result ( $result)
protectedinherited

Saves the results to an array.

Parameters
array$resultassociative array
Return values
void

◆ add_used()

base_nested_element::add_used ( $element)
protectedinherited

Reimplemented in base_optigroup.

◆ clean_value()

base_nested_element::clean_value ( )
inherited

Reimplemented from base_atom.

◆ clean_values()

base_nested_element::clean_values ( )
inherited

Reimplemented from base_final_element.

◆ destroy()

base_nested_element::destroy ( )
inherited

Destroy all circular references.

It helps PHP 5.2 a lot!

Reimplemented from base_final_element.

◆ fill_values()

backup_nested_element::fill_values ( $values)
inherited

Simple filler that, matching by name, will fill both attributes and final elements depending of this nested element, debugging info about non-matching elements and/or elements present in both places.

Accept both arrays and objects.

◆ get_iterator()

backup_nested_element::get_iterator ( $processor)
protectedinherited

Returns one PHP iterator over each "ocurrence" of this nested element (array or DB recordset).

Delegated to backup_structure_dbops class

Reimplemented in backup_logstore_database_nested_element.

◆ get_level()

backup_optigroup_element::get_level ( )

Return the level of this element, that will be, the level of the parent (doesn't consume level) (note this os only a "cosmetic" effect (to_string) as fact as the real responsible for this is the corresponding structure_processor for the final output.

Reimplemented from base_final_element.

◆ get_logs()

backup_nested_element::get_logs ( )
inherited

Returns the logs.

Return values
arrayof log objects

◆ get_new_attribute()

backup_optigroup_element::get_new_attribute ( $name)
protected

Instantiating attributes is forbidden.

Reimplemented from backup_nested_element.

◆ get_new_final_element()

backup_optigroup_element::get_new_final_element ( $name)
protected

Returns one instace of the @final_element class to work with when final_elements are added simply by name.

Reimplemented from backup_nested_element.

◆ get_results()

backup_nested_element::get_results ( )
inherited

Returns the results.

Return values
associativearray of results

◆ get_value()

base_nested_element::get_value ( )
inherited

Reimplemented from base_atom.

◆ process()

backup_optigroup_element::process ( $processor)

process one optigroup_element

Note that this ONLY processes the final elements in order to get all them before processing any nested element. Pending nested elements are processed by the optigroup caller.

Reimplemented from backup_nested_element.

◆ set_parent()

backup_optigroup_element::set_parent ( $element)
protected

Set the parent of the optigroup_element and, at the same time, process the condition param.

Reimplemented from base_final_element.

◆ set_value()

base_nested_element::set_value ( $value)
inherited

Reimplemented from base_atom.

◆ to_string()

base_nested_element::to_string ( $showvalue = false)
inherited

Reimplemented from base_final_element.


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