Moodle PHP Documentation 4.2
Moodle 4.2.8 (Build: 20240610) (2d41ac46f45)
restore_decode_rule Class Reference

Helper class used to decode links back to their original form. More...

Public Member Functions

 __construct (string $linkname, string $urltemplate, $mappings, bool $urlencoded=false)
 Constructor.
 
 decode ($content)
 
 set_restoreid ($restoreid)
 
 set_wwwroots ($sourcewwwroot, $targetwwwroot)
 

Protected Member Functions

 apply_modifications ($toreplace, $mappingsok)
 Apply other modifications, based in the result of $mappingsok before placeholder replacements.
 
 get_calculated_regexp ()
 based on rule definition, build the regular expression to execute on decode
 
 get_mapping ($itemname, $itemid)
 Looks for mapping values in backup_ids table, simple wrapper over get_backup_ids_record.
 
 validate_params ($linkname, $urltemplate, $mappings)
 Perform all the validations and checks on the rule attributes.
 

Protected Attributes

 $cregexp
 
 $linkname
 
 $mappings
 
 $restoreid
 
 $sourcewwwroot
 
 $targetwwwroot
 
bool bool $urlencoded
 $urlencoded Whether to use urlencode() on the final URL.
 
 $urltemplate
 

Detailed Description

Helper class used to decode links back to their original form.

This class allows each restore task to specify the changes that will be applied to any encoded (by backup) link to revert it back to its original form, recoding any parameter as needed.

TODO: Complete phpdocs

Constructor & Destructor Documentation

◆ __construct()

restore_decode_rule::__construct ( string $linkname,
string $urltemplate,
$mappings,
bool $urlencoded = false )

Constructor.

Parameters
string$linknameHow the link has been encoded in backup (CHOICEVIEWBYID, COURSEVIEWBYID...)
string$urltemplateHow the original URL looks like, with dollar placeholders
array | string$mappingsWhich backup_ids mappings do we need to apply for replacing the placeholders
bool$urlencodedWhether to use urlencode() on the final URL (defaults to false)

Member Function Documentation

◆ apply_modifications()

restore_decode_rule::apply_modifications ( $toreplace,
$mappingsok )
protected

Apply other modifications, based in the result of $mappingsok before placeholder replacements.

Right now, simply prefix with the proper wwwroot (source/target)


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