mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 06:05:56 +00:00
Optimization for SiteTree::allowedChildren()
Adds an `Object::extend('updateAllowedChildren')` whilst also caching the default response Using `get_class($this)` as cache key as this is what is used in `Configurable::stat($name)` to retrieve the candidates
This commit is contained in:
parent
bd86251043
commit
0570df95a8
@ -2467,8 +2467,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
public function allowedChildren()
|
||||
{
|
||||
if (isset(static::$_allowedChildren[$this->ClassName])) {
|
||||
return static::$_allowedChildren[$this->ClassName];
|
||||
}
|
||||
$allowedChildren = static::$_allowedChildren[$this->ClassName];
|
||||
} else {
|
||||
// Get config based on old FIRST_SET rules
|
||||
$candidates = null;
|
||||
$class = get_class($this);
|
||||
@ -2498,9 +2498,12 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
|
||||
$allowedChildren[] = $subclass;
|
||||
}
|
||||
}
|
||||
static::$_allowedChildren[get_class($this)] = $allowedChildren;
|
||||
}
|
||||
}
|
||||
$this->extend('updateAllowedChildren', $allowedChildren);
|
||||
|
||||
return static::$_allowedChildren[$this->ClassName] = $allowedChildren;
|
||||
return $allowedChildren;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user