mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUGFIX Added optional $context flag to Hierarchy->AllChildrenIncludingDeleted() (merged from branches/translatable in r64523, thanks wakeless!)
BUGFIX Added extension point for augmentAllChildrenIncludingDeleted(), augmentNumChildrenCountQuery(), augmentStageChildren() in Hierarchy (merged from branches/translatable in r64523, thanks wakeless!) git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69893 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
23ed38765c
commit
dae382b537
@ -33,7 +33,7 @@ class Hierarchy extends DataObjectDecorator {
|
||||
$this->markingFinished();
|
||||
}
|
||||
|
||||
$children = $this->owner->AllChildrenIncludingDeleted();
|
||||
$children = $this->owner->AllChildrenIncludingDeleted($extraArg);
|
||||
|
||||
if($children) {
|
||||
if($attributes) {
|
||||
@ -381,7 +381,17 @@ class Hierarchy extends DataObjectDecorator {
|
||||
* Everything else has "SameOnStage" set, as an indicator that this information has been looked up.
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
public function AllChildrenIncludingDeleted() {
|
||||
public function AllChildrenIncludingDeleted($context = null) {
|
||||
return $this->doAllChildrenIncludingDeleted($context);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see AllChildrenIncludingDeleted
|
||||
*
|
||||
* @param unknown_type $context
|
||||
* @return DataObjectSet
|
||||
*/
|
||||
public function doAllChildrenIncludingDeleted($context = null) {
|
||||
// Cache the allChildren data, so that future requests will return the references to the same
|
||||
// object. This allows the mark..() system to work appropriately.
|
||||
|
||||
@ -391,6 +401,8 @@ class Hierarchy extends DataObjectDecorator {
|
||||
$stageChildren = $this->owner->stageChildren(true);
|
||||
$this->allChildrenIncludingDeleted = $stageChildren;
|
||||
|
||||
$this->owner->extend("augmentAllChildrenIncludingDeleted", $stageChildren, $context);
|
||||
|
||||
// Add live site content, if required.
|
||||
if($this->owner->hasExtension('Versioned')) {
|
||||
// Get all the requisite data, and index it
|
||||
@ -467,6 +479,7 @@ class Hierarchy extends DataObjectDecorator {
|
||||
// We build the query in an extension-friendly way.
|
||||
$query = new SQLQuery("COUNT(*)","`$baseClass`","ParentID = " . (int)$this->owner->ID);
|
||||
$this->owner->extend('augmentSQL', $query);
|
||||
$this->owner->extend('augmentNumChildrenCountQuery', $query);
|
||||
return $query->execute()->value();
|
||||
}
|
||||
|
||||
@ -478,7 +491,9 @@ class Hierarchy extends DataObjectDecorator {
|
||||
public function stageChildren($showAll = false) {
|
||||
$extraFilter = $showAll ? '' : " AND ShowInMenus = 1";
|
||||
$baseClass = ClassInfo::baseDataClass($this->owner->class);
|
||||
return DataObject::get($baseClass, "`{$baseClass}`.`ParentID` = " . (int)$this->owner->ID . " AND `{$baseClass}`.ID != " . (int)$this->owner->ID . $extraFilter, "");
|
||||
$staged = DataObject::get($baseClass, "`{$baseClass}`.`ParentID` = " . (int)$this->owner->ID . " AND `{$baseClass}`.ID != " . (int)$this->owner->ID . $extraFilter, "");
|
||||
$this->owner->extend("augmentStageChildren", $staged, $showAll);
|
||||
return $staged;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user