diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index bbd3ada8cd..c349ebed0e 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -1096,7 +1096,7 @@ private function buildEditFormBreadcrumb(ArrayList $items, SiteTree $page, bool $this->pushCrumb( $items, $ancestor->getMenuTitle(), - $unlinked ? false : $ancestor->CMSEditLink() + $unlinked ? false : $ancestor->getCMSEditLink() ); } } @@ -1109,13 +1109,13 @@ private function buildListViewBreadcrumb(ArrayList $items, SiteTree $page): void // Find all ancestors of the provided page $ancestors = $page->getAncestors(true); $ancestors = array_reverse($ancestors->toArray() ?? []); - + //turns the title and link of the breadcrumbs into template-friendly variables $params = array_filter([ 'view' => $this->getRequest()->getVar('view'), 'q' => $this->getRequest()->getVar('q') ]); - + foreach ($ancestors as $ancestor) { // Link back to the list view for the current ancestor $params['ParentID'] = $ancestor->ID; @@ -1710,7 +1710,7 @@ public function ListViewForm() /** @var SiteTree $item */ $title = sprintf( '%s', - $item->CMSEditLink(), + $item->getCMSEditLink(), $item->TreeTitle // returns HTML, does its own escaping ); $breadcrumbs = $item->Breadcrumbs(20, true, false, true, '/'); @@ -2103,7 +2103,7 @@ public function doRollback($data, $form) // Can be used in different contexts: In normal page edit view, in which case the redirect won't have any effect. // Or in history view, in which case a revert causes the CMS to re-load the edit view. // The X-Pjax header forces a "full" content refresh on redirect. - $url = $record->CMSEditLink(); + $url = $record->getCMSEditLink(); $this->getResponse()->addHeader('X-ControllerURL', $url); $this->getRequest()->addHeader('X-Pjax', 'Content'); $this->getResponse()->addHeader('X-Pjax', 'Content'); @@ -2220,7 +2220,7 @@ public function duplicate(HTTPRequest $request): HTTPResponse ['title' => $newPage->Title] ) ?? '') ); - $url = $newPage->CMSEditLink(); + $url = $newPage->getCMSEditLink(); $this->getResponse()->addHeader('X-ControllerURL', $url); $this->getRequest()->addHeader('X-Pjax', 'Content'); $this->getResponse()->addHeader('X-Pjax', 'Content'); @@ -2256,7 +2256,7 @@ public function duplicatewithchildren(HTTPRequest $request): HTTPResponse ['title' => $newPage->Title] ) ?? '') ); - $url = $newPage->CMSEditLink(); + $url = $newPage->getCMSEditLink(); $this->getResponse()->addHeader('X-ControllerURL', $url); $this->getRequest()->addHeader('X-Pjax', 'Content'); $this->getResponse()->addHeader('X-Pjax', 'Content'); diff --git a/code/Controllers/SilverStripeNavigatorItem_CMSLink.php b/code/Controllers/SilverStripeNavigatorItem_CMSLink.php index eb888e67a2..1da2692cbf 100644 --- a/code/Controllers/SilverStripeNavigatorItem_CMSLink.php +++ b/code/Controllers/SilverStripeNavigatorItem_CMSLink.php @@ -16,7 +16,7 @@ public function getHTML() { return sprintf( '%s', - $this->record->CMSEditLink(), + $this->record->getCMSEditLink(), _t('SilverStripe\\CMS\\Controllers\\ContentController.CMS', 'CMS') ); } @@ -28,7 +28,7 @@ public function getTitle() public function getLink() { - return $this->record->CMSEditLink(); + return $this->record->getCMSEditLink(); } public function isActive() diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index 5d33539ad7..a3d97f9986 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -285,7 +285,6 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi 'Link' => 'Text', 'RelativeLink' => 'Text', 'AbsoluteLink' => 'Text', - 'CMSEditLink' => 'Text', 'TreeTitle' => 'HTMLFragment', 'MetaTags' => 'HTMLFragment', ]; @@ -758,20 +757,6 @@ public function getAbsoluteLiveLink($includeStageEqualsLive = true) return $link; } - /** - * Generates a link to edit this page in the CMS. - * - * Implemented here to satisfy the CMSPreviewable interface, but data is intended to be loaded via Extension - * - * @see SilverStripe\Admin\CMSEditLinkExtension - * - * @return string - */ - public function CMSEditLink() - { - return $this->extend('CMSEditLink')[0] ?? ''; - } - /** * Return a CSS identifier generated from this page's link. * @@ -1504,7 +1489,7 @@ public function MetaComponents() $tags['cmsEditLink'] = [ 'attributes' => [ 'name' => 'x-cms-edit-link', - 'content' => $this->CMSEditLink(), + 'content' => $this->getCMSEditLink(), ], ]; } @@ -2157,11 +2142,11 @@ public function getCMSFields() 'Untitled {instanceType}', ['instanceType' => $item->i18n_singular_name()] ); - $tag = $item->hasMethod('CMSEditLink') ? 'a' : 'span'; + $tag = $item->hasMethod('getCMSEditLink') ? 'a' : 'span'; return sprintf( '<%s%s class="dependent-content__edit-link %s">%s', $tag, - $tag === 'a' ? sprintf(' href="%s"', $item->CMSEditLink()) : '', + $tag === 'a' ? sprintf(' href="%s"', $item->getCMSEditLink()) : '', $title ? '' : 'dependent-content__edit-link--untitled', $title ? Convert::raw2xml($title) : $untitled, $tag diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index a65cd1f275..704c814b95 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -258,7 +258,7 @@ public function getCMSFields() 'a', [ 'class' => 'cmsEditlink', - 'href' => $this->CopyContentFrom()->CMSEditLink(), + 'href' => $this->CopyContentFrom()->getCMSEditLink(), ], _t(VirtualPage::class . '.EditLink', 'edit') ); diff --git a/tests/php/Model/SiteTreeTest.php b/tests/php/Model/SiteTreeTest.php index ce09e7cb4e..82485baf02 100644 --- a/tests/php/Model/SiteTreeTest.php +++ b/tests/php/Model/SiteTreeTest.php @@ -1505,7 +1505,7 @@ public function testMetaTags() $this->assertStringContainsString('assertStringContainsString('assertStringContainsString('assertStringContainsString('assertStringContainsString('assertStringContainsString('HTML & XML', $meta); // Test without title @@ -1566,7 +1566,7 @@ public function testMetaComponents() 'cmsEditLink' => [ 'attributes' => [ 'name' => 'x-cms-edit-link', - 'content' => $page->CMSEditLink() + 'content' => $page->getCMSEditLink() ] ] ]; @@ -2084,11 +2084,11 @@ public function testCMSEditLink() $child = $this->objFromFixture(BelongsToPage::class, 'one'); $this->assertSame( "http://localhost/admin/pages/edit/show/$page->ID", - $page->CMSEditLink() + $page->getCMSEditLink() ); $this->assertSame( "http://localhost/admin/pages/edit/show/$page->ID/field/ChildObjects/item/$child->ID", - $child->CMSEditLink() + $child->getCMSEditLink() ); } diff --git a/tests/php/Model/VirtualPageTest.php b/tests/php/Model/VirtualPageTest.php index 2185ef1764..9512cd35e7 100644 --- a/tests/php/Model/VirtualPageTest.php +++ b/tests/php/Model/VirtualPageTest.php @@ -105,7 +105,7 @@ public function testMetaTags() $this->assertStringContainsString('assertStringContainsString('assertStringContainsString('assertStringContainsString('assertStringContainsString('assertStringContainsString(''.$master->Title.'', $meta); }