Moodle PHP Documentation 4.5
Moodle 4.5dev (Build: 20240606) (d3ae1391abe)
core\output\mustache_helper_collection Class Reference

Custom Moodle helper collection for mustache. More...

Inheritance diagram for core\output\mustache_helper_collection:
Mustache_HelperCollection

Public Member Functions

 __construct ($helpers=null, array $disallowednestedhelpers=[])
 Helper Collection constructor.
 
 __get ($name)
 Magic accessor.
 
 __isset ($name)
 Magic isset().
 
 __set ($name, $helper)
 Magic mutator.
 
 __unset ($name)
 Magic unset().
 
 add ($name, $helper)
 Add a helper to this collection.
 
 clear ()
 Clear the helper collection.
 
 get ($name)
 Get a helper by name.
 
 has ($name)
 Check whether a given helper is present in the collection.
 
 isEmpty ()
 Check whether the helper collection is empty.
 
 remove ($name)
 Check whether a given helper is present in the collection.
 
 strip_blacklisted_helpers ()
 
 strip_disallowed_helpers ($disallowedlist, $string)
 Parse the given string and remove any reference to disallowed helpers.
 

Detailed Description

Custom Moodle helper collection for mustache.

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

Constructor & Destructor Documentation

◆ __construct()

core\output\mustache_helper_collection::__construct ( $helpers = null,
array $disallowednestedhelpers = [] )

Helper Collection constructor.

Optionally accepts an array (or Traversable) of $name => $helper pairs.

Exceptions
Mustache_Exception_InvalidArgumentExceptionif the $helpers argument isn't an array or Traversable
Parameters
array | Traversable$helpers(default: null)
string[]$disallowednestedhelpersNames of helpers that aren't allowed to be called within other helpers.

Member Function Documentation

◆ __get()

Mustache_HelperCollection::__get ( $name)
inherited

Magic accessor.

See also
Mustache_HelperCollection\get
Parameters
string$name
Return values
mixedHelper

◆ __isset()

Mustache_HelperCollection::__isset ( $name)
inherited

Magic isset().

See also
Mustache_HelperCollection\has
Parameters
string$name
Return values
boolTrue if helper is present

◆ __set()

Mustache_HelperCollection::__set ( $name,
$helper )
inherited

Magic mutator.

See also
Mustache_HelperCollection\add
Parameters
string$name
mixed$helper

◆ __unset()

Mustache_HelperCollection::__unset ( $name)
inherited

Magic unset().

See also
Mustache_HelperCollection\remove
Parameters
string$name

◆ add()

core\output\mustache_helper_collection::add ( $name,
$helper )

Add a helper to this collection.

This function has overridden the parent implementation to provide disallowing functionality for certain helpers to prevent them being called from within other helpers. This is because the JavaScript helper can be used in a security exploit if it can be nested.

The function will wrap callable helpers in an anonymous function that strips out the disallowed helpers from the source string before giving it to the helper function. This prevents the disallowed helper functions from being called by nested render functions from within other helpers.

See also
Mustache_HelperCollection\add()
Parameters
string$name
mixed$helper

Reimplemented from Mustache_HelperCollection.

◆ clear()

Mustache_HelperCollection::clear ( )
inherited

Clear the helper collection.

Removes all helpers from this collection

◆ get()

Mustache_HelperCollection::get ( $name)
inherited

Get a helper by name.

Exceptions
Mustache_Exception_UnknownHelperExceptionIf helper does not exist
Parameters
string$name
Return values
mixedHelper

◆ has()

Mustache_HelperCollection::has ( $name)
inherited

Check whether a given helper is present in the collection.

Parameters
string$name
Return values
boolTrue if helper is present

◆ isEmpty()

Mustache_HelperCollection::isEmpty ( )
inherited

Check whether the helper collection is empty.

Return values
boolTrue if the collection is empty

◆ remove()

Mustache_HelperCollection::remove ( $name)
inherited

Check whether a given helper is present in the collection.

Exceptions
Mustache_Exception_UnknownHelperExceptionif the requested helper is not present
Parameters
string$name

◆ strip_blacklisted_helpers()

core\output\mustache_helper_collection::strip_blacklisted_helpers ( )
Deprecated
Deprecated since Moodle 3.10 (MDL-69050) - use {
See also
strip_disallowed_helpers}

◆ strip_disallowed_helpers()

core\output\mustache_helper_collection::strip_disallowed_helpers ( $disallowedlist,
$string )

Parse the given string and remove any reference to disallowed helpers.

E.g. $disallowedlist = ['js']; $string = "core, move, {{#js}} some nasty JS hack {{/js}}" result: "core, move, {{}}"

Parameters
string[]$disallowedlistList of helper names to strip
string$stringString to parse
Return values
stringParsed string

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