From 6f1b166d9989d215756a9a8d5c0104552484bda9 Mon Sep 17 00:00:00 2001 From: Ralph Slooten Date: Tue, 26 Sep 2017 14:10:45 +1300 Subject: [PATCH] Fix excludeSiteTreeClassNames (#64) --- src/Model/Lumberjack.php | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/Model/Lumberjack.php b/src/Model/Lumberjack.php index 0693680..834a5fc 100644 --- a/src/Model/Lumberjack.php +++ b/src/Model/Lumberjack.php @@ -100,21 +100,25 @@ public function stageChildren($showAll = false) } $this->owner->extend("augmentStageChildren", $staged, $showAll); - $this->excludeSiteTreeClassNames($staged); + $staged = $this->excludeSiteTreeClassNames($staged); return $staged; } /** - * Excludes any hidden owner subclasses + * Excludes any hidden owner subclasses. Note that the returned DataList will be a different + * instance from the original. + * * @param DataList $list + * @return DataList */ protected function excludeSiteTreeClassNames($list) { $classNames = $this->owner->getExcludedSiteTreeClassNames(); if ($this->shouldFilter() && count($classNames)) { // Filter the SiteTree - $list->exclude('ClassName', $classNames); + $list = $list->exclude('ClassName', $classNames); } + return $list; } /** @@ -156,7 +160,7 @@ public function liveChildren($showAll = false, $onlyDeletedFromStage = false) if (!$showAll && DataObject::getSchema()->fieldSpec($this->owner, 'ShowInMenus')) { $children = $children->filter('ShowInMenus', 1); } - $this->excludeSiteTreeClassNames($children); + $children = $this->excludeSiteTreeClassNames($children); return $children; }