Version: current

# Class Hierarchy

DataObjects that use the Hierachy decorator can be be organised as a hierachy, with children and parents. The most obvious example of this is SiteTree.

  Extension
  DataObjectDecorator
  Hierarchy

Package: sapphire\model
Located at sapphire/core/model/Hierarchy.php

## Methods summary

`public` | # `augmentSQL( `SQLQuery` & $query )` Edit the given query object to support queries for this extension Edit the given query object to support queries for this extension #### Parameters $query SQLQuery $query Query to augment. #### Overrides `DataObjectDecorator::augmentSQL`
`public` | # `augmentDatabase( )` Update the database schema as required by this extension. Update the database schema as required by this extension. #### Overrides `DataObjectDecorator::augmentDatabase`
`public` | # `augmentWrite( `SQLQuery` & $manipulation )` Augment a write-record request. Augment a write-record request. #### Parameters $manipulation SQLQuery $manipulation Query to augment. #### Overrides `DataObjectDecorator::augmentWrite`
`public string` | # `getChildrenAsUL( string $attributes = "", string $titleEval = '"<li>" . $child->Title', string $extraArg = null, boolean $limitToMarked = false, string $childrenMethod = "AllChildrenIncludingDeleted", boolean $numChildrenMethod = "numChildren", integer $rootCall = true, mixed $minNodeCount = 30 )` 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. 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. #### Parameters $attributes string $attributes Attributes to add to the UL. $titleEval string $titleEval PHP code to evaluate to start each child - this should include '' $extraArg string $extraArg Extra arguments that will be passed on to children, for if they overload this function. $limitToMarked boolean $limitToMarked Display only marked children. $childrenMethod string $childrenMethod The name of the method used to get children from each object $numChildrenMethod boolean $rootCall Set to true for this first call, and then to false for calls inside the recursion. You should not change this. $rootCall int $minNodeCount $minNodeCount #### Returns `string` string
`public integer` | # `markPartialTree( integer $minNodeCount = 30, mixed $context = null, mixed $childrenMethod = "AllChildrenIncludingDeleted", mixed $numChildrenMethod = "numChildren" )` 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. 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 isExpanded() and isMarked() on individual nodes. #### Parameters $minNodeCount int $minNodeCount The minimum amount of nodes to mark. $context $childrenMethod $numChildrenMethod #### Returns `integer` The actual number of nodes marked.
`public` | # `setMarkingFilter( string $parameterName, mixed $parameterValue )` Filter the marking to only those object with $node->$parameterName = $parameterValue Filter the marking to only those object with $node->$parameterName = $parameterValue #### Parameters $parameterName string $parameterName The parameter on each node to check when marking. $parameterValue mixed $parameterValue The value the parameter must be to be marked.
`public` | # `setMarkingFilterFunction( string $funcName )` Filter the marking to only those where the function returns true. The node in question will be passed to the function. Filter the marking to only those where the function returns true. The node in question will be passed to the function. #### Parameters $funcName string $funcName The function name.
`public boolean` | # `markingFilterMatches( `DataObject` $node )` Returns true if the marking filter matches on the given node. Returns true if the marking filter matches on the given node. #### Parameters $node DataObject $node Node to check. #### Returns `boolean` boolean
`public` | # `markChildren( `DataObject` $node, mixed $context = null, mixed $childrenMethod = "AllChildrenIncludingDeleted", mixed $numChildrenMethod = "numChildren" )` Mark all children of the given node that match the marking filter. Mark all children of the given node that match the marking filter. #### Parameters $node DataObject $node Parent node. $context $childrenMethod $numChildrenMethod
`protected` | # `markingFinished( mixed $numChildrenMethod = "numChildren" )` Ensure marked nodes that have children are also marked expanded. Call this after marking but before iterating over the tree. Ensure marked nodes that have children are also marked expanded. Call this after marking but before iterating over the tree.
`public` | # `markingClasses( )` Return CSS classes of 'unexpanded', 'closed', both, or neither, depending on the marking of this DataObject. Return CSS classes of 'unexpanded', 'closed', both, or neither, depending on the marking of this DataObject.
`public` | # `markById( integer $id, boolean $open = false )` Mark the children of the DataObject with the given ID. Mark the children of the DataObject with the given ID. #### Parameters $id int $id ID of parent node. $open boolean $open If this is true, mark the parent node as opened.
`public` | # `markToExpose( `DataObject` $childObj )` Expose the given object in the tree, by marking this page and all it ancestors. Expose the given object in the tree, by marking this page and all it ancestors. #### Parameters $childObj DataObject $childObj
`public` | # `markedNodeIDs( )` Return the IDs of all the marked nodes Return the IDs of all the marked nodes
`public array` | # `parentStack( )` Return an array of this page and its ancestors, ordered item -> root. Return an array of this page and its ancestors, ordered item -> root. #### Returns `array` array
`public` | # `markExpanded( )` Mark this DataObject as expanded. Mark this DataObject as expanded.
`public` | # `markUnexpanded( )` Mark this DataObject as unexpanded. Mark this DataObject as unexpanded.
`public` | # `markOpened( )` Mark this DataObject's tree as opened. Mark this DataObject's tree as opened.
`public boolean` | # `isMarked( )` Check if this DataObject is marked. Check if this DataObject is marked. #### Returns `boolean` boolean
`public boolean` | # `isExpanded( )` Check if this DataObject is expanded. Check if this DataObject is expanded. #### Returns `boolean` boolean
`public` | # `isTreeOpened( )` Check if this DataObject's tree is opened. Check if this DataObject's tree is opened.
`public` | # `partialTreeAsUL( mixed $minCount = 50 )` Return a partial tree as an HTML UL. Return a partial tree as an HTML UL.
`public integer` | # `getDescendantIDList( )` Get a list of this DataObject's and all it's descendants IDs. Get a list of this DataObject's and all it's descendants IDs. #### Returns `integer` int
`public` | # `loadDescendantIDListInto( mixed & $idList )` Get a list of this DataObject's and all it's descendants ID, and put it in $idList. Get a list of this DataObject's and all it's descendants ID, and put it in $idList. #### Var array $idList Array to put results in.
`public `DataObjectSet`` | # `Children( )` Get the children for this DataObject. Get the children for this DataObject. #### Returns ``DataObjectSet`` DataObjectSet
`public `DataObjectSet`` | # `AllChildren( mixed $st = 1 )` Return all children, including those 'not in menus'. Return all children, including those 'not in menus'. #### Returns ``DataObjectSet`` DataObjectSet
`public `DataObjectSet`` | # `AllChildrenIncludingDeleted( mixed $context = null )` Return all children, including those that have been deleted but are still in live. Deleted children will be marked as "DeletedFromStage" Added children will be marked as "AddedToStage" Modified children will be marked as "ModifiedOnStage" Everything else has "SameOnStage" set, as an indicator that this information has been looked up. Return all children, including those that have been deleted but are still in live. Deleted children will be marked as "DeletedFromStage" Added children will be marked as "AddedToStage" Modified children will be marked as "ModifiedOnStage" Everything else has "SameOnStage" set, as an indicator that this information has been looked up. #### Returns ``DataObjectSet`` DataObjectSet
`public `DataObjectSet`` | # `doAllChildrenIncludingDeleted( unknown_type $context = null )` #### Parameters $context unknown_type $context #### Returns ``DataObjectSet`` DataObjectSet #### See ``Hierarchy::AllChildrenIncludingDeleted()``
`public` | # `AllHistoricalChildren( )` Return all the children that this page had, including pages that were deleted from both stage & live. Return all the children that this page had, including pages that were deleted from both stage & live.
`public` | # `numHistoricalChildren( )` Return the number of children that this page ever had, including pages that were deleted Return the number of children that this page ever had, including pages that were deleted
`public integer` | # `numChildren( `Boolean` $cache = true )` Return the number of direct children. By default, values are cached after the first invocation. Can be augumented by augmentNumChildrenCountQuery(). Return the number of direct children. By default, values are cached after the first invocation. Can be augumented by augmentNumChildrenCountQuery(). #### Parameters $cache Boolean $cache #### Returns `integer` int
`public `DataObjectSet`` | # `stageChildren( showAll $showAll = false )` Return children from the stage site Return children from the stage site #### Parameters $showAll showAll Inlcude all of the elements, even those not shown in the menus. (only applicable when extension is applied to `SiteTree`). #### Returns ``DataObjectSet`` DataObjectSet
`public `DataObjectSet`` | # `liveChildren( boolean $showAll = false, boolean $onlyDeletedFromStage = false )` Return children from the live site, if it exists. Return children from the live site, if it exists. #### Parameters $showAll boolean $showAll Include all of the elements, even those not shown in the menus. (only applicable when extension is applied to `SiteTree`). $onlyDeletedFromStage boolean $onlyDeletedFromStage Only return items that have been deleted from stage #### Returns ``DataObjectSet`` DataObjectSet
`public `DataObject`` | # `getParent( mixed $filter = '' )` Get the parent of this class. Get the parent of this class. #### Returns ``DataObject`` DataObject
`public `DataObjectSet`` | # `getAncestors( )` Return all the parents of this class in a set ordered from the lowest to highest parent. Return all the parents of this class in a set ordered from the lowest to highest parent. #### Returns ``DataObjectSet`` DataObjectSet
`public` | # `naturalPrev( mixed $className, mixed $afterNode = null )` Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents. Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents.
`public `DataObject`` | # `naturalNext( string $className = null, string|integer $root = 0, `DataObject` $afterNode = null )` Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents. Get the next node in the tree of the type. If there is no instance of the className descended from this node, then search the parents. #### Parameters $className string $className Class name of the node to find. $root string|int $root ID/ClassName of the node to limit the search to $afterNode DataObject afterNode Used for recursive calls to this function #### Returns ``DataObject`` DataObject
`public` | # `flushCache( )` Clear any internal caches. Clear any internal caches. #### Overrides `DataObjectDecorator::flushCache`

### Methods inherited from DataObjectDecorator

`can()`, `canCreate()`, `canDelete()`, `canEdit()`, `extraStatics()`, `load_extra_statics()`, `onAfterDelete()`, `onAfterWrite()`, `onBeforeDelete()`, `onBeforeWrite()`, `populateDefaults()`, `requireDefaultRecords()`, `updateCMSActions()`, `updateCMSFields()`, `updateFieldLabels()`, `updateFrontEndFields()`, `updateSummaryFields()`

### Methods inherited from Extension

`__construct()`, `clearOwner()`, `getOwner()`, `get_classname_without_arguments()`, `setOwner()`

### Magic methods summary

## Properties summary

`protected mixed` | $markedNodes | #
`protected mixed` | $markingFilter | #
`protected `Int`` | $_cache_numChildren | #
`protected static boolean` | $marked | # True if this DataObject is marked. True if this DataObject is marked.
`protected static boolean` | $expanded | # True if this DataObject is expanded. True if this DataObject is expanded.
`protected static boolean` | $treeOpened | # True if this DataObject is opened. True if this DataObject is opened.

### Properties inherited from DataObjectDecorator

`$decoratable_statics`

### Properties inherited from Extension

`$allowed_actions`, `$class`, `$owner`, `$ownerBaseClass`

[Raise a SilverStripe Framework issue/bug](https://github.com/silverstripe/silverstripe-framework/issues/new)
- [Raise a SilverStripe CMS issue/bug](https://github.com/silverstripe/silverstripe-cms/issues/new)
- Please use the Silverstripe Forums to ask development related questions. -