Class representing a path to be converted from XML file.
More...
|
| validate_name ($name) |
| end of public API //////////////////////////////////////////////////////
|
|
| validate_pobject ($pobject) |
| Makes sure that the given object is a valid processing object.
|
|
|
array | $dropfields = array() |
| of deprecated fields that are dropped
|
|
string | $emethod = null |
| the name of the path end event handler
|
|
bool | $grouped |
| flag to define if this element will get child ones grouped or no
|
|
string | $name |
| name of the element
|
|
array | $newfields = array() |
| of new fields to add and their initial values
|
|
string | $path |
| path within the XML file this element will handle
|
|
string | $pmethod = null |
| the name of the processing method
|
|
object | $pobject = null |
| object instance in charge of processing this element.
|
|
array | $renamefields = array() |
| of fields renaming
|
|
string | $smethod = null |
| the name of the path start event handler
|
|
mixed | $tags = null |
| last data read for this element or returned data by processing method
|
|
Class representing a path to be converted from XML file.
This was created as a copy of restore_path_element and should be refactored probably.
◆ __construct()
convert_path::__construct |
( |
| $name, |
|
|
| $path, |
|
|
array | $recipe = array(), |
|
|
| $grouped = false ) |
Constructor.
The optional recipe array can have three keys, and for each key, the value is another array.
- newfields => array fieldname => defaultvalue indicates fields that have been added to the table, and so should be added to the XML.
- dropfields => array fieldname indicates fieldsthat have been dropped from the table, and so can be dropped from the XML.
- renamefields => array oldname => newname indicates fieldsthat have been renamed in the table, and so should be renamed in the XML. {
- Parameters
-
string | $name | name of the element |
string | $path | path of the element |
array | $recipe | basic description of the structure conversion |
bool | $grouped | to gather information in grouped mode or no |
◆ apply_recipes()
convert_path::apply_recipes |
( |
array | $data | ) |
|
Cooks the parsed tags data by applying known recipes.
Recipes are used for common trivial operations like adding new fields or renaming fields. The handler's processing method receives cooked data.
- Parameters
-
array | $data | the contents of the element |
- Return values
-
◆ get_end_method()
convert_path::get_end_method |
( |
| ) |
|
- Return values
-
string | the name of the path end event listener |
◆ get_name()
convert_path::get_name |
( |
| ) |
|
- Return values
-
string | the element given name |
◆ get_path()
convert_path::get_path |
( |
| ) |
|
- Return values
-
string | the path to the element |
◆ get_processing_method()
convert_path::get_processing_method |
( |
| ) |
|
- Return values
-
string | the name of the method to call to process the element |
◆ get_processing_object()
convert_path::get_processing_object |
( |
| ) |
|
- Return values
-
object | the processing object providing the processing method |
◆ get_start_method()
convert_path::get_start_method |
( |
| ) |
|
- Return values
-
string | the name of the path start event listener |
◆ get_tags()
convert_path::get_tags |
( |
| ) |
|
◆ is_grouped()
convert_path::is_grouped |
( |
| ) |
|
- Return values
-
bool | flag to define if this element will get child ones grouped or no |
◆ set_dropped_fields()
convert_path::set_dropped_fields |
( |
array | $fields | ) |
|
Sets the list of deprecated fields to drop.
- Parameters
-
◆ set_end_method()
convert_path::set_end_method |
( |
| $emethod | ) |
|
Sets the name of the path end event listener.
- Parameters
-
◆ set_new_fields()
convert_path::set_new_fields |
( |
array | $fields | ) |
|
Sets the new fields and their values.
- Parameters
-
array | $fields | (string)$field => (mixed)value |
◆ set_processing_method()
convert_path::set_processing_method |
( |
| $pmethod | ) |
|
Sets the name of the processing method.
- Parameters
-
◆ set_processing_object()
convert_path::set_processing_object |
( |
| $pobject | ) |
|
Validates and sets the given processing object.
- Parameters
-
object | $pobject | processing object, must provide a method to be called |
◆ set_renamed_fields()
convert_path::set_renamed_fields |
( |
array | $fields | ) |
|
Sets the required new names of the current fields.
- Parameters
-
array | $fields | (string)$currentname => (string)$newname |
◆ set_start_method()
convert_path::set_start_method |
( |
| $smethod | ) |
|
Sets the name of the path start event listener.
- Parameters
-
◆ set_tags()
convert_path::set_tags |
( |
| $tags | ) |
|
Sets the element tags.
- Parameters
-
◆ validate_name()
convert_path::validate_name |
( |
| $name | ) |
|
|
protected |
end of public API //////////////////////////////////////////////////////
Makes sure the given name is a valid element name
Note it may look as if we used exceptions for code flow control here. That's not the case as we actually validate the code, not the user data. And the code is supposed to be correct.
- Parameters
-
- Exceptions
-
- Return values
-
◆ validate_pobject()
convert_path::validate_pobject |
( |
| $pobject | ) |
|
|
protected |
Makes sure that the given object is a valid processing object.
The processing object must be an object providing at least element's processing method or path-reached-end event listener or path-reached-start listener method.
Note it may look as if we used exceptions for code flow control here. That's not the case as we actually validate the code, not the user data. And the code is supposed to be correct.
- Parameters
-
- Exceptions
-
- Return values
-
The documentation for this class was generated from the following file:
- backup/converter/moodle1/lib.php