mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
ENHANCEMENT Support for anonymous functions instead of eval() in Hierarchy->getSiteTreeAsUL()
This commit is contained in:
parent
35d4cd3da8
commit
761bae3418
@ -34,7 +34,7 @@ class Hierarchy extends DataExtension {
|
||||
* Returns the children of this DataObject as an XHTML UL. This will be called recursively on each child,
|
||||
* so if they have children they will be displayed as a UL inside a LI.
|
||||
* @param string $attributes Attributes to add to the UL.
|
||||
* @param string $titleEval PHP code to evaluate to start each child - this should include '<li>'
|
||||
* @param string|callable $titleEval PHP code to evaluate to start each child - this should include '<li>'
|
||||
* @param string $extraArg Extra arguments that will be passed on to children, for if they overload this function.
|
||||
* @param boolean $limitToMarked Display only marked children.
|
||||
* @param string $childrenMethod The name of the method used to get children from each object
|
||||
@ -64,7 +64,8 @@ class Hierarchy extends DataExtension {
|
||||
foreach($children as $child) {
|
||||
if(!$limitToMarked || $child->isMarked()) {
|
||||
$foundAChild = true;
|
||||
$output .= eval("return $titleEval;") . "\n" .
|
||||
$output .= (is_callable($titleEval)) ? $titleEval($child) : eval("return $titleEval;");
|
||||
$output .= "\n" .
|
||||
$child->getChildrenAsUL("", $titleEval, $extraArg, $limitToMarked, $childrenMethod, $numChildrenMethod, false, $minNodeCount) . "</li>\n";
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user