MarkedSet
class MarkedSet (View source)
Contains a set of hierarchical objects generated from a marking compilation run.
A set of nodes can be "marked" for later export, in order to prevent having to export the entire contents of a potentially huge tree.
Traits
A class that can be instantiated or replaced via DI
Properties
array | $markingFilter | Optional filter callback for filtering nodes to mark |
Methods
An implementation of the factory method, allows you to create an instance of a class
Creates a class instance by the "singleton" design pattern.
Create an empty set with the given class
Get total number of nodes to get. This acts as a soft lower-bounds for number of nodes to search until found.
Max number of nodes that can be physically rendered at any level.
Set hard limit of number of nodes to get for this level
Set max node count
Get method to use for getting children
Set method to use for getting children
Get method name for num children
Set method name to get num children
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.
Get child data formatted as JSON
Mark a segment of the tree, by calling mark().
Filter the marking to only those object with $node->$parameterName == $parameterValue
Filter the marking to only those where the function returns true. The node in question will be passed to the function.
Mark the children of the DataObject with the given ID.
Expose the given object in the tree, by marking this page and all it ancestors.
Return the IDs of all the marked nodes.
Reset marked nodes
Toggle limiting on or off
Check if limiting is enabled
Details
static Injectable
create(array ...$args)
An implementation of the factory method, allows you to create an instance of a class
This method will defer class substitution to the Injector API, which can be customised via the Config API to declare substitution classes.
This can be called in one of two ways - either calling via the class directly, or calling on Object and passing the class name as the first parameter. The following are equivalent: $list = DataList::create('SiteTree'); $list = SiteTree::get();
static Injectable
singleton(string $class = null)
Creates a class instance by the "singleton" design pattern.
It will always return the same instance for this class, which can be used for performance reasons and as a simple way to access instance methods which don't rely on instance data (e.g. the custom SilverStripe static handling).
__construct(DataObject $rootNode, string $childrenMethod = null, string $numChildrenMethod = null, int $nodeCountThreshold = null, int $maxChildNodes = null)
Create an empty set with the given class
int
getNodeCountThreshold()
Get total number of nodes to get. This acts as a soft lower-bounds for number of nodes to search until found.
Defaults to value of node_threshold_total of hierarchy class.
int
getMaxChildNodes()
Max number of nodes that can be physically rendered at any level.
Acts as a hard upper bound, after which nodes will be trimmed for performance reasons.
$this
setMaxChildNodes(int $count)
Set hard limit of number of nodes to get for this level
$this
setNodeCountThreshold(int $total)
Set max node count
string
getChildrenMethod()
Get method to use for getting children
$this
setChildrenMethod(string $method)
Set method to use for getting children
string
getNumChildrenMethod()
Get method name for num children
$this
setNumChildrenMethod(string $method)
Set method name to get num children
string
renderChildren(string $template = null, array|callable $context = [])
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.
array
getChildrenAsArray(callable $serialiseEval = null)
Get child data formatted as JSON
$this
markPartialTree()
Mark a segment of the tree, by calling mark().
The method performs a breadth-first traversal until the number of nodes is more than minCount. This is used to get a limited number of tree nodes to show in the CMS initially.
This method returns the number of nodes marked. After this method is called other methods can check {@link isExpanded()} and {@link isMarked()} on individual nodes.
$this
setMarkingFilter(string $parameterName, mixed $parameterValue)
Filter the marking to only those object with $node->$parameterName == $parameterValue
$this
setMarkingFilterFunction(callable $callback)
Filter the marking to only those where the function returns true. The node in question will be passed to the function.
bool
markById(int $id, bool $open = false)
Mark the children of the DataObject with the given ID.
$this
markToExpose(DataObject $childObj)
Expose the given object in the tree, by marking this page and all it ancestors.
array
markedNodeIDs()
Return the IDs of all the marked nodes.
clearMarks()
Reset marked nodes
$this
markExpanded(DataObject $node)
Mark this DataObject as expanded.
$this
markUnexpanded(DataObject $node)
Mark this DataObject as unexpanded.
$this
markOpened(DataObject $node)
Mark this DataObject's tree as opened.
$this
markClosed(DataObject $node)
Mark this DataObject's tree as closed.
bool
isMarked(DataObject $node)
Check if this DataObject is marked.
bool
isExpanded(DataObject $node)
Check if this DataObject is expanded.
An expanded object has had it's children iterated through.
bool
isTreeOpened(DataObject $node)
Check if this DataObject's tree is opened.
This is an expanded node which also should have children visually shown.
$this
setLimitingEnabled(bool $enabled)
Toggle limiting on or off
bool
getLimitingEnabled()
Check if limiting is enabled