diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index f8e2b9d19c..0d6c13417e 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -684,7 +684,7 @@ public function getMimeType() public function RelativeLink($action = null) { if ($this->ParentID && self::config()->get('nested_urls')) { - $parent = $this->Parent(); + $parent = $this->getParent(); // If page is removed select parent from version history (for archive page view) if ((!$parent || !$parent->exists()) && !$this->isOnDraft()) { $parent = Versioned::get_latest_version(self::class, $this->ParentID); @@ -809,7 +809,7 @@ public function isOrphaned() } // Parent must exist and not be an orphan itself - $parent = $this->Parent(); + $parent = $this->getParent(); return !$parent || !$parent->exists() || $parent->isOrphaned(); } @@ -863,7 +863,7 @@ public function InSection($sectionName) if ($sectionName === $page->URLSegment) { return true; } - $page = $page->Parent(); + $page = $page->getParent(); } return false; } @@ -966,7 +966,7 @@ public function getBreadcrumbItems($maxDepth = 20, $stopAtPageType = false, $sho $pages[] = $page; } - $page = $page->Parent(); + $page = $page->getParent(); } return new ArrayList(array_reverse($pages ?? [])); @@ -995,13 +995,13 @@ public function setParent($item) /** * Get the parent of this page. * - * @return SiteTree Parent of this page + * @return SiteTree|null */ public function getParent() { $parentID = $this->getField("ParentID"); if ($parentID) { - return SiteTree::get_by_id(self::class, $parentID); + return SiteTree::get_by_id($parentID); } return null; } @@ -1176,7 +1176,7 @@ public function canView($member = null) // check for inherit if ($this->CanViewType === InheritedPermissions::INHERIT) { if ($this->ParentID) { - return $this->Parent()->canView($member); + return $this->getParent()->canView($member); } else { return $this->getSiteConfig()->canViewPages($member); } @@ -1872,7 +1872,7 @@ public function validURLSegment() // Check known urlsegment blacklists if (self::config()->get('nested_urls') && $this->ParentID) { // Guard against url segments for sub-pages - $parent = $this->Parent(); + $parent = $this->getParent(); if ($controller = ModelAsController::controller_for($parent)) { if ($controller instanceof Controller && $controller->hasAction($this->URLSegment)) { return false; @@ -2132,7 +2132,7 @@ public function getCMSFields() $baseLink = Controller::join_links( Director::absoluteBaseURL(), - (self::config()->get('nested_urls') && $this->ParentID ? $this->Parent()->RelativeLink(true) : null) + (self::config()->get('nested_urls') && $this->ParentID ? $this->getParent()->RelativeLink(true) : null) ); $urlsegment = SiteTreeURLSegmentField::create("URLSegment", $this->fieldLabel('URLSegment')) @@ -2755,7 +2755,7 @@ protected function getClassDropdown() if ($instance instanceof HiddenClass) { continue; } - if (!$instance->canCreate(null, ['Parent' => $this->ParentID ? $this->Parent() : null])) { + if (!$instance->canCreate(null, ['Parent' => $this->ParentID ? $this->getParent() : null])) { continue; } } @@ -3033,7 +3033,7 @@ public function Level($level) { $parent = $this; $stack = [$parent]; - while (($parent = $parent->Parent()) && $parent->exists()) { + while (($parent = $parent->getParent()) && $parent->exists()) { array_unshift($stack, $parent); } @@ -3048,7 +3048,7 @@ public function Level($level) public function getPageLevel() { if ($this->ParentID) { - return 1 + $this->Parent()->getPageLevel(); + return 1 + $this->getParent()->getPageLevel(); } return 1; }