Hierarchy
class Hierarchy extends DataExtension (View source)
DataObjects that use the Hierarchy extension can be be organised as a hierarchy, with children and parents. The most obvious example of this is SiteTree.
Properties
DataObject|Hierarchy | $owner | ||
static private int | $node_threshold_total | The lower bounds for the amount of nodes to mark. If set, the logic will expand nodes until it reaches at least this number, and then stops. Root nodes will always show regardless of this settting. Further nodes can be lazy-loaded via ajax. This isn't a hard limit. Example: On a value of 10, with 20 root nodes, each having 30 children, the actual node count will be 50 (all root nodes plus first expanded child). |
|
static private int | $node_threshold_leaf | Limit on the maximum children a specific node can display. Serves as a hard limit to avoid exceeding available server resources in generating the tree, and browser resources in rendering it. Nodes with children exceeding this value typically won't display any children, although this is configurable through the $nodeCountCallback parameter in {@link getChildrenAsUL()}. "Root" nodes will always show all children, regardless of this setting. |
|
static private array | $hide_from_hierarchy | A list of classnames to exclude from display in both the CMS and front end displays. ->Children() and ->AllChildren affected. |
|
static private array | $hide_from_cms_tree | A list of classnames to exclude from display in the page tree views of the CMS, unlike $hide_from_hierarchy above which effects both CMS and front end. |
|
static private bool | $prepopulate_numchildren_cache | Used to enable or disable the prepopulation of the numchildren cache. |
|
static private array | $non_virtual_fields | Prevent virtual page virtualising these fields |
|
int | $ParentID |
Methods
Called when this extension is added to a particular class
Temporarily modify the owner. The original owner is ensured to be restored
Clear the current owner, and restore extension to the state prior to the last setOwner()
Helper method to strip eval'ed arguments from a string that's passed to {@link DataObject::$extensions} or {@link Object::add_extension()}.
Invoke extension point. This will prefer explicit extend
prefixed
methods.
Validate the owner object - check for existence of infinite loops.
Edit the given query object to support queries for this extension
Define extra database fields
This function is used to provide modifications to the form in the CMS by the extension. By default, no changes are made. {@link DataObject->getCMSFields()}.
This function is used to provide modifications to the form used for front end forms. {@link DataObject->getFrontEndFields()}
This is used to provide modifications to the form actions used in the CMS. {@link DataObject->getCMSActions()}.
this function is used to provide modifications to the summary fields in CMS by the extension By default, the summaryField() of its owner will merge more fields defined in the extension's $extra_fields['summary_fields']
this function is used to provide modifications to the fields labels in CMS by the extension By default, the fieldLabels() of its owner will merge more fields defined in the extension's $extra_fields['field_labels']
No description
Get a list of this DataObject's and all it's descendants IDs.
Return all children, including those 'not in menus'.
Return all children, including those that have been deleted but are still in live.
Return all the children that this page had, including pages that were deleted from both stage & live.
Return the number of children that this page ever had, including pages that were deleted.
Return the number of direct children. By default, values are cached after the first invocation. Can be augumented by {@link augmentNumChildrenCountQuery()}.
Pre-populate any appropriate caches prior to rendering a tree.
Pre-populate the cache for Versioned::get_versionnumber_by_stage() for a list of record IDs, for more efficient database querying. If $idList is null, then every record will be pre-cached.
Checks if we're on a controller where we should filter. ie. Are we loading the SiteTree?
Return children in the stage site.
Return children in the live site, if it exists.
Get this object's parent, optionally filtered by an SQL clause. If the clause doesn't match the parent, nothing is returned.
Return all the parents of this class in a set ordered from the closest to furtherest parent.
Returns a human-readable, flattened representation of the path to the object, using its {@link Title} attribute.
No description
Details
__construct()
static
add_to_class(string $class, string $extensionClass, mixed $args = null)
Called when this extension is added to a particular class
setOwner(object $owner)
Set the owner of this extension.
mixed
withOwner(mixed $owner, callable $callback, array $args = [])
Temporarily modify the owner. The original owner is ensured to be restored
clearOwner()
Clear the current owner, and restore extension to the state prior to the last setOwner()
object
getOwner()
Returns the owner of this extension.
static string
get_classname_without_arguments(string $extensionStr)
Helper method to strip eval'ed arguments from a string that's passed to {@link DataObject::$extensions} or {@link Object::add_extension()}.
mixed
invokeExtension(object $owner, string $method, array ...$arguments)
Invoke extension point. This will prefer explicit extend
prefixed
methods.
static
unload_extra_statics($class, $extension)
validate(ValidationResult $validationResult)
Validate the owner object - check for existence of infinite loops.
augmentSQL(SQLSelect $query, DataQuery $dataQuery = null)
Edit the given query object to support queries for this extension
augmentDatabase()
Update the database schema as required by this extension.
When duplicating a table's structure, remember to duplicate the create options as well. See {@link Versioned->augmentDatabase} for an example.
augmentWrite(array $manipulation)
Augment a write-record request.
onBeforeWrite()
onAfterWrite()
onBeforeDelete()
onAfterDelete()
requireDefaultRecords()
populateDefaults()
can($member)
canEdit($member)
canDelete($member)
canCreate($member)
array
extraStatics(string $class = null, string $extension = null)
Define extra database fields
Return a map where the keys are db, has_one, etc, and the values are additional fields/relations to be defined.
updateCMSFields(FieldList $fields)
This function is used to provide modifications to the form in the CMS by the extension. By default, no changes are made. {@link DataObject->getCMSFields()}.
Please consider using {@link updateFormFields()} to globally add formfields to the record. The method {@link updateCMSFields()} should just be used to add or modify tabs, or fields which are specific to the CMS-context.
Caution: Use {@link FieldList->addFieldToTab()} to add fields.
updateFrontEndFields(FieldList $fields)
This function is used to provide modifications to the form used for front end forms. {@link DataObject->getFrontEndFields()}
Caution: Use {@link FieldList->push()} to add fields.
updateCMSActions(FieldList $actions)
This is used to provide modifications to the form actions used in the CMS. {@link DataObject->getCMSActions()}.
updateSummaryFields(array $fields)
this function is used to provide modifications to the summary fields in CMS by the extension By default, the summaryField() of its owner will merge more fields defined in the extension's $extra_fields['summary_fields']
updateFieldLabels(array $labels)
this function is used to provide modifications to the fields labels in CMS by the extension By default, the fieldLabels() of its owner will merge more fields defined in the extension's $extra_fields['field_labels']
static
get_extra_config($class, $extension, $args)
int[]
getDescendantIDList()
Get a list of this DataObject's and all it's descendants IDs.
SS_List
Children()
Get the children for this DataObject filtered by canView()
DataList
AllChildren()
Return all children, including those 'not in menus'.
ArrayList
AllChildrenIncludingDeleted()
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.
DataList
AllHistoricalChildren()
Return all the children that this page had, including pages that were deleted from both stage & live.
int
numHistoricalChildren()
Return the number of children that this page ever had, including pages that were deleted.
int
numChildren(bool $cache = true)
Return the number of direct children. By default, values are cached after the first invocation. Can be augumented by {@link augmentNumChildrenCountQuery()}.
prepopulateTreeDataCache(DataList|array $recordList = null, array $options = [])
Pre-populate any appropriate caches prior to rendering a tree.
This is used to allow for the efficient rendering of tree views, notably in the CMS. In the cace of Hierarchy, it caches numChildren values. Other extensions can provide an onPrepopulateTreeDataCache(DataList $recordList = null, array $options) methods to hook into this event as well.
static
prepopulate_numchildren_cache($baseClass, array $idList = null)
Pre-populate the cache for Versioned::get_versionnumber_by_stage() for a list of record IDs, for more efficient database querying. If $idList is null, then every record will be pre-cached.
bool
showingCMSTree()
Checks if we're on a controller where we should filter. ie. Are we loading the SiteTree?
DataList
stageChildren(bool $showAll = false, bool $skipParentIDFilter = false)
Return children in the stage site.
DataList
liveChildren(bool $showAll = false, bool $onlyDeletedFromStage = false)
Return children in the live site, if it exists.
DataObject
getParent(string $filter = null)
Get this object's parent, optionally filtered by an SQL clause. If the clause doesn't match the parent, nothing is returned.
ArrayList
getAncestors(bool $includeSelf = false)
Return all the parents of this class in a set ordered from the closest to furtherest parent.
string
getBreadcrumbs(string $separator = ' » ')
Returns a human-readable, flattened representation of the path to the object, using its {@link Title} attribute.
flushCache()
Flush all Hierarchy caches:
- Children (instance)
- NumChildren (instance)