-
-
Save robbieaverill/9a185078f1883daf30ff039e00c504b4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php | |
index 85be8e33..859f41de 100755 | |
--- a/code/Model/SiteTree.php | |
+++ b/code/Model/SiteTree.php | |
@@ -1727,10 +1727,11 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi | |
/** | |
* Get the back-link tracking objects that link to this page | |
* | |
- * @retun ArrayList|DataObject[] | |
+ * @return DataList|DataObject[] | |
*/ | |
public function BackLinkTracking() | |
{ | |
+ return $this->BackLinks(); | |
// @todo - Implement PolymorphicManyManyList to replace this | |
$list = ArrayList::create(); | |
foreach ($this->BackLinks() as $link) { | |
@@ -1747,7 +1748,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi | |
* Returns the pages that depend on this page. This includes virtual pages, pages that link to it, etc. | |
* | |
* @param bool $includeVirtuals Set to false to exlcude virtual pages. | |
- * @return ArrayList|SiteTree[] | |
+ * @return DataList|SiteTree[] | |
*/ | |
public function DependentPages($includeVirtuals = true) | |
{ | |
@@ -1757,43 +1758,30 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi | |
} | |
// Content links | |
- $items = new ArrayList(); | |
+ $items = DataList::create(SiteTree::class); | |
+ $filterByIds = []; | |
- // We merge all into a regular SS_List, because DataList doesn't support merge | |
if ($contentLinks = $this->BackLinkTracking()) { | |
- $linkList = new ArrayList(); | |
- foreach ($contentLinks as $item) { | |
- $item->DependentLinkType = 'Content link'; | |
- $linkList->push($item); | |
- } | |
- $items->merge($linkList); | |
+ $filterByIds = array_merge($filterByIds, $contentLinks->column('ID')); | |
} | |
// Virtual pages | |
if ($includeVirtuals) { | |
$virtuals = $this->VirtualPages(); | |
- if ($virtuals) { | |
- $virtualList = new ArrayList(); | |
- foreach ($virtuals as $item) { | |
- $item->DependentLinkType = 'Virtual page'; | |
- $virtualList->push($item); | |
- } | |
- $items->merge($virtualList); | |
- } | |
+ $filterByIds = array_merge($filterByIds, $virtuals->column('ID')); | |
} | |
// Redirector pages | |
- $redirectors = RedirectorPage::get()->where(array( | |
+ $redirectors = RedirectorPage::get()->where([ | |
'"RedirectorPage"."RedirectionType"' => 'Internal', | |
'"RedirectorPage"."LinkToID"' => $this->ID | |
- )); | |
+ ]); | |
if ($redirectors) { | |
- $redirectorList = new ArrayList(); | |
- foreach ($redirectors as $item) { | |
- $item->DependentLinkType = 'Redirector page'; | |
- $redirectorList->push($item); | |
- } | |
- $items->merge($redirectorList); | |
+ $filterByIds = array_merge($filterByIds, $redirectors->column('ID')); | |
+ } | |
+ | |
+ if (count($filterByIds)) { | |
+ $items = $items->filter(['ID' => $filterByIds]); | |
} | |
if (class_exists('Subsite')) { |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment