mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #4979 from dhensby/pulls/3/SilbinaryWolf-minor-optimization
Replaced filterByCallback for 'Children' to just create a new array a…
This commit is contained in:
commit
790a6da24e
@ -20,10 +20,13 @@ class ClassInfo {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @todo Improve documentation
|
* Returns true if a class or interface name exists.
|
||||||
|
*
|
||||||
|
* @param string $class
|
||||||
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public static function exists($class) {
|
public static function exists($class) {
|
||||||
return SS_ClassLoader::instance()->classExists($class);
|
return class_exists($class, false) || interface_exists($class, false) || SS_ClassLoader::instance()->getItemPath($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -101,7 +101,8 @@ class SS_ClassLoader {
|
|||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function classExists($class) {
|
public function classExists($class) {
|
||||||
return class_exists($class, false) || interface_exists($class, false) || $this->getItemPath($class);
|
Deprecation::notice('4.0', 'Use ClassInfo::exists.');
|
||||||
|
return ClassInfo::exists($class);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -493,9 +493,13 @@ class Hierarchy extends DataExtension {
|
|||||||
public function Children() {
|
public function Children() {
|
||||||
if(!(isset($this->_cache_children) && $this->_cache_children)) {
|
if(!(isset($this->_cache_children) && $this->_cache_children)) {
|
||||||
$result = $this->owner->stageChildren(false);
|
$result = $this->owner->stageChildren(false);
|
||||||
$this->_cache_children = $result->filterByCallback(function($item) {
|
$children = array();
|
||||||
return $item->canView();
|
foreach ($result as $record) {
|
||||||
});
|
if ($record->canView()) {
|
||||||
|
$children[] = $record;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$this->_cache_children = new ArrayList($children);
|
||||||
}
|
}
|
||||||
return $this->_cache_children;
|
return $this->_cache_children;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user