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
protected | T | $owner | The object this extension is applied to. |
from Extension |
protected static | array | $cache_numChildren | A cache used by numChildren(). |
|
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 DataObject::$extensions or 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
Update the database schema as required by this extension.
Influence the owner's can() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
Influence the owner's canEdit() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
Influence the owner's canDelete() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
Influence the owner's canCreate() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
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. DataObject->getCMSFields().
This function is used to provide modifications to the Validators used on a DataObject.
This function is used to provide modifications to the form used for front end forms. DataObject->getFrontEndFields()
This is used to provide modifications to the form actions used in the CMS. 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']
Get a list of this DataObject's and all it's descendants ID, and put them in $idList.
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 augmented by 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 Title attribute.
Details
__construct()
No description
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()
T
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 DataObject::$extensions or Object::add_extension().
mixed
invokeExtension(object $owner, string $method, array ...$arguments)
Invoke extension point. This will prefer explicit extend
prefixed
methods.
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 Versioned->augmentDatabase for an example.
augmentWrite(array $manipulation)
Augment a write-record request.
onBeforeWrite()
Extend the owner's onBeforeWrite() logic
See DataObject::onBeforeWrite() for context.
onAfterWrite()
Extend the owner's onAfterWrite() logic
See DataObject::onAfterWrite() for context.
onBeforeDelete()
Extend the owner's onBeforeDelete() logic
See DataObject::onBeforeDelete() for context.
onAfterDelete()
Extend the owner's onAfterDelete() logic
See DataObject::onAfterDelete() for context.
requireDefaultRecords()
Extend the owner's requireDefaultRecords() logic
See DataObject::requireDefaultRecords() for context.
populateDefaults()
Extend the owner's populateDefaults() logic
See DataObject::populateDefaults() for context.
onAfterBuild()
Extend the owner's onAfterBuild() logic
See DataObject::onAfterBuild() for context.
bool|null
can(Member $member)
Influence the owner's can() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
See DataObject::can()} and {@link DataObject::extendedCan() for context.
bool|null
canEdit(Member $member)
Influence the owner's canEdit() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
See DataObject::canEdit()} and {@link DataObject::extendedCan() for context.
bool|null
canDelete(Member $member)
Influence the owner's canDelete() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
See DataObject::canDelete()} and {@link DataObject::extendedCan() for context.
bool|null
canCreate(Member $member)
Influence the owner's canCreate() permission check value to be disallowed (false), allowed (true) if no other processed results are to disallow, or open (null) to not affect the outcome.
See DataObject::canCreate()} and {@link DataObject::extendedCan() for context.
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. DataObject->getCMSFields().
Please consider using updateFormFields() to globally add formfields to the record. The method updateCMSFields() should just be used to add or modify tabs, or fields which are specific to the CMS-context.
Caution: Use FieldList->addFieldToTab() to add fields.
void
updateCMSCompositeValidator(CompositeValidator $compositeValidator)
This function is used to provide modifications to the Validators used on a DataObject.
Caution: Use CompositeValidator->addValidator() to add Validators.
updateFrontEndFields(FieldList $fields)
This function is used to provide modifications to the form used for front end forms. DataObject->getFrontEndFields()
Caution: Use FieldList->push() to add fields.
updateCMSActions(FieldList $actions)
This is used to provide modifications to the form actions used in the CMS. 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)
No description
int[]
getDescendantIDList()
Get a list of this DataObject's and all it's descendants IDs.
protected
loadDescendantIDListInto(array $idList, DataObject|Hierarchy $node = null)
Get a list of this DataObject's and all it's descendants ID, and put them in $idList.
DataObject&static>
Children()
Get the children for this DataObject filtered by canView()
DataObject&static>
AllChildren()
Return all children, including those 'not in menus'.
DataObject&static>
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.
DataObject&static>
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 augmented by 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 case 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(string $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?
DataObject&static>
stageChildren(bool $showAll = false, bool $skipParentIDFilter = false)
Return children in the stage site.
DataObject&static>
liveChildren(bool $showAll = false, bool $onlyDeletedFromStage = false)
Return children in the live site, if it exists.
DataObject&Hierarchy
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.
DataObject&static>
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 Title attribute.
flushCache()
Flush all Hierarchy caches:
- Children (instance)
- NumChildren (instance)
DataObject
Parent()
No description