From fd919b2c5e2aaf092f7b1199d6e742aefd0c55e4 Mon Sep 17 00:00:00 2001 From: Guy Sartorelli Date: Mon, 9 Dec 2024 12:56:01 +1300 Subject: [PATCH] API Deprecate API that's being removed in CMS 6 --- code/Controllers/CMSMain.php | 218 +++++++++++++++--- code/Controllers/CMSPageAddController.php | 18 +- .../Controllers/CMSPageSettingsController.php | 2 +- code/Controllers/CMSPagesController.php | 14 ++ code/Controllers/CMSSiteTreeFilter.php | 9 + .../LeftAndMainPageIconsExtension.php | 29 ++- code/Model/CurrentPageIdentifier.php | 3 + code/Model/RedirectorPage.php | 3 + code/Model/SiteTree.php | 41 ++++ code/Model/VirtualPage.php | 3 + 10 files changed, 309 insertions(+), 31 deletions(-) diff --git a/code/Controllers/CMSMain.php b/code/Controllers/CMSMain.php index c6a003fcda..a905fe1e00 100644 --- a/code/Controllers/CMSMain.php +++ b/code/Controllers/CMSMain.php @@ -87,7 +87,13 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr /** * Unique ID for page icons CSS block */ - const PAGE_ICONS_ID = 'PageIcons'; + public const CMS_RECORD_ICONS_ID = 'PageIcons'; + + /** + * Unique ID for page icons CSS block + * @deprecated 5.4.0 use CMS_RECORD_ICONS_ID instead + */ + const PAGE_ICONS_ID = CMSMain::CMS_RECORD_ICONS_ID; private static $url_segment = 'pages'; @@ -143,6 +149,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr 'schema', 'SearchForm', 'SiteTreeAsUL', + 'TreeAsUL', 'getshowdeletedsubtree', 'savetreenode', 'getsubtree', @@ -162,14 +169,17 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr 'TreeIsFiltered' => 'Boolean', 'AddForm' => 'HTMLFragment', 'LinkPages' => 'Text', + 'LinkRecords' => 'Text', 'Link' => 'Text', 'ListViewForm' => 'HTMLFragment', 'ExtraTreeTools' => 'HTMLFragment', 'PageList' => 'HTMLFragment', 'PageListSidebar' => 'HTMLFragment', 'SiteTreeHints' => 'HTMLFragment', + 'TreeHints' => 'HTMLFragment', 'SecurityID' => 'Text', 'SiteTreeAsUL' => 'HTMLFragment', + 'TreeAsUL' => 'HTMLFragment', ]; private static $dependencies = [ @@ -201,7 +211,7 @@ public function index(HTTPRequest $request): HTTPResponse // In case we're not showing a specific record, explicitly remove any session state, // to avoid it being highlighted in the tree, and causing an edit form to show. if (!$request->param('Action')) { - $this->setCurrentPageID(null); + $this->setCurrentRecordID(null); } return parent::index($request); @@ -223,9 +233,11 @@ public function getResponseNegotiator(): PjaxResponseNegotiator * Get pages listing area * * @return DBHTMLText + * @deprecated 5.4.0 Will be renamed to RecordList */ public function PageList() { + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be renamed to RecordList'); return $this->renderWith($this->getTemplatesWithSuffix('_PageList')); } @@ -233,9 +245,11 @@ public function PageList() * Page list view for edit-form * * @return DBHTMLText + * @deprecated 5.4.0 Will be removed without equivalent functionality */ public function PageListSidebar() { + Deprecation::noticeWithNoReplacment('5.4.0'); return $this->renderWith($this->getTemplatesWithSuffix('_PageList_Sidebar')); } @@ -260,7 +274,7 @@ public function ShowSwitchView() public function SwitchView($page = null) { if (!$page) { - $page = $this->currentPage(); + $page = $this->currentRecord(); } if ($page) { @@ -293,14 +307,32 @@ public function Link($action = null) return $link; } + /** + * @deprecated 5.4.0 Use LinkRecords instead + */ public function LinkPages() + { + Deprecation::notice('5.4.0', 'Use LinkRecords() instead.'); + return $this->LinkRecords(); + } + + public function LinkRecords() { return CMSPagesController::singleton()->Link(); } + /** + * @deprecated 5.4.0 Use LinkRecordsWithSearch instead + */ public function LinkPagesWithSearch() { - return $this->LinkWithSearch($this->LinkPages()); + Deprecation::notice('5.4.0', 'Use LinkRecordsWithSearch() instead.'); + return $this->LinkRecordsWithSearch(); + } + + public function LinkRecordsWithSearch() + { + return $this->LinkWithSearch($this->LinkRecords()); } /** @@ -379,19 +411,37 @@ public function getCMSEditLinkForManagedDataObject(SiteTree $obj): string return Controller::join_links(CMSPageEditController::singleton()->Link('show'), $obj->ID); } + /** + * @deprecated 5.4.0 Use LinkRecordEdit() instead. + */ public function LinkPageEdit($id = null) + { + Deprecation::notice('5.4.0', 'Use LinkRecordEdit() instead.'); + return $this->LinkRecordEdit($id); + } + + public function LinkRecordEdit($id = null) { if (!$id) { - $id = $this->currentPageID(); + $id = $this->currentRecordID(); } return $this->LinkWithSearch( Controller::join_links(CMSPageEditController::singleton()->Link('show'), $id) ); } + /** + * @deprecated 5.4.0 Use LinkRecordSettings() instead. + */ public function LinkPageSettings() { - if ($id = $this->currentPageID()) { + Deprecation::notice('5.4.0', 'Use LinkRecordSettings() instead.'); + return $this->LinkRecordSettings(); + } + + public function LinkRecordSettings() + { + if ($id = $this->currentRecordID()) { return $this->LinkWithSearch( Controller::join_links(CMSPageSettingsController::singleton()->Link('show'), $id) ); @@ -400,10 +450,19 @@ public function LinkPageSettings() } } + /** + * @deprecated 5.4.0 Use LinkRecordHistory() instead. + */ public function LinkPageHistory() + { + Deprecation::notice('5.4.0', 'Use LinkRecordHistory() instead.'); + return $this->LinkRecordHistory(); + } + + public function LinkRecordHistory() { $controller = Injector::inst()->get(CMSPageHistoryViewerController::class); - if (($id = $this->currentPageID()) && $controller) { + if (($id = $this->currentRecordID()) && $controller) { if ($controller) { return $this->LinkWithSearch( Controller::join_links($controller->Link('show'), $id) @@ -467,7 +526,16 @@ public function LinkWithSearch($link) return $link; } + /** + * @deprecated 5.4.0 Use LinkRecordAdd() instead. + */ public function LinkPageAdd($extra = null, $placeholders = null) + { + Deprecation::notice('5.4.0', 'Use LinkRecordAdd() instead.'); + return $this->LinkRecordAdd($extra, $placeholders); + } + + public function LinkRecordAdd($extra = null, $placeholders = null) { $link = CMSPageAddController::singleton()->Link(); $this->extend('updateLinkPageAdd', $link); @@ -485,10 +553,12 @@ public function LinkPageAdd($extra = null, $placeholders = null) /** * @return string + * @deprecated 5.4.0 Use SilverStripe\CMS\Model\SiteTree::CMSEditLink() instead. */ public function LinkPreview() { - $record = $this->getRecord($this->currentPageID()); + Deprecation::notice('5.4.0', 'Use ' . SiteTree::class . '::CMSEditLink() instead.'); + $record = $this->getRecord($this->currentRecordID()); $baseLink = Director::absoluteBaseURL(); if ($record && $record instanceof SiteTree) { // if we are an external redirector don't show a link @@ -503,8 +573,18 @@ public function LinkPreview() /** * Return the entire site tree as a nested set of ULs + * @deprecated 5.4.0 Use TreeAsUL() instead. */ public function SiteTreeAsUL() + { + Deprecation::notice('5.4.0', 'Use TreeAsUL() instead.'); + return $this->TreeAsUL(); + } + + /** + * Return the entire tree as a nested set of ULs + */ + public function TreeAsUL() { $treeClass = $this->config()->get('tree_class'); $filter = $this->getSearchFilter(); @@ -514,7 +594,7 @@ public function SiteTreeAsUL() 'numChildrenMethod' => $filter ? $filter->getNumChildrenMethod() : 'numChildren', ]); - $html = $this->getSiteTreeFor($treeClass); + $html = $this->getTreeFor($treeClass); $this->extend('updateSiteTreeAsUL', $html); @@ -533,6 +613,7 @@ public function SiteTreeAsUL() * @param callable $filterFunction * @param int $nodeCountThreshold * @return string Nested unordered list with links to each page + * @deprecated 5.4.0 Use getTreeFor() instead. */ public function getSiteTreeFor( $className, @@ -541,6 +622,38 @@ public function getSiteTreeFor( $numChildrenMethod = null, $filterFunction = null, $nodeCountThreshold = null + ) { + Deprecation::notice('5.4.0', 'Use getTreeFor() instead.'); + return $this->getTreeFor( + $className, + $rootID, + $childrenMethod, + $numChildrenMethod, + $filterFunction, + $nodeCountThreshold + ); + } + + /** + * Get a tree HTML listing which displays the nodes under the given criteria. + * + * @param string $className The class of the root object + * @param string $rootID The ID of the root object. If this is null then a complete tree will be + * shown + * @param string $childrenMethod The method to call to get the children of the tree. For example, + * Children, AllChildrenIncludingDeleted, or AllHistoricalChildren + * @param string $numChildrenMethod + * @param callable $filterFunction + * @param int $nodeCountThreshold + * @return string Nested unordered list with links to each record + */ + public function getTreeFor( + $className, + $rootID = null, + $childrenMethod = null, + $numChildrenMethod = null, + $filterFunction = null, + $nodeCountThreshold = null ) { $nodeCountThreshold = is_null($nodeCountThreshold) ? Config::inst()->get($className, 'node_threshold_total') : $nodeCountThreshold; // Provide better defaults from filter @@ -573,7 +686,7 @@ public function getSiteTreeFor( $markingSet->markPartialTree(); // Ensure current page is exposed - $currentPage = $this->currentPage(); + $currentPage = $this->currentRecord(); if ($currentPage) { $markingSet->markToExpose($currentPage); } @@ -658,7 +771,7 @@ public function getTreeNodeClasses(SiteTree $node) */ public function getsubtree(HTTPRequest $request): HTTPResponse { - $html = $this->getSiteTreeFor( + $html = $this->getTreeFor( $this->config()->get('tree_class'), $request->getVar('ID'), null, @@ -754,7 +867,7 @@ public function savetreenode(HTTPRequest $request): HTTPResponse if (!SecurityToken::inst()->checkRequest($request)) { $this->httpError(400); } - if (!$this->CanOrganiseSitetree()) { + if (!$this->canOrganiseTree()) { $this->httpError( 403, _t( @@ -863,12 +976,21 @@ public function savetreenode(HTTPRequest $request): HTTPResponse /** * Whether the current member has the permission to reorganise SiteTree objects. * @return bool + * @deprecated 5.4.0 Use canOrganiseTree instead. */ public function CanOrganiseSitetree() { - return Permission::check('SITETREE_REORGANISE'); + Deprecation::notice('5.4.0', 'Use canOrganiseTree instead.'); + return $this->canOrganiseTree(); } + /** + * Whether the current member has the permission to reorganise SiteTree objects. + */ + public function canOrganiseTree(): bool + { + return Permission::check('SITETREE_REORGANISE'); + } /** * @return boolean @@ -891,9 +1013,11 @@ public function ExtraTreeTools() * and can be modified on extensions through updateSearchContext * * @return \SilverStripe\ORM\Search\SearchContext + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Model\SiteTree::getDefaultSearchContext(). */ public function getSearchContext() { + Deprecation::notice('5.4.0', 'Will be replaced with ' . SiteTree::class . '::getDefaultSearchContext().'); $context = SiteTree::singleton()->getDefaultSearchContext(); $this->extend('updateSearchContext', $context); @@ -963,7 +1087,7 @@ public function getSearchForm() $pageClasses = DropdownField::create( 'Search__ClassName', _t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEOPT', 'Page type', 'Dropdown for limiting search to a page type'), - $this->getPageTypes() + $this->getRecordTypes() ); $pageClasses->setEmptyString(_t('SilverStripe\\CMS\\Controllers\\CMSMain.PAGETYPEANYOPT', 'Any')); @@ -1007,15 +1131,25 @@ public function getSearchForm() * Returns a sorted array suitable for a dropdown with pagetypes and their translated name * * @return array + * @deprecated 5.4.0 Use getRecordTypes() instead. */ protected function getPageTypes() { - $pageTypes = []; - foreach (SiteTree::page_type_classes() as $pageTypeClass) { - $pageTypes[$pageTypeClass] = SiteTree::singleton($pageTypeClass)->i18n_singular_name(); + Deprecation::notice('5.4.0', 'Use getRecordTypes() instead.'); + return $this->getRecordTypes(); + } + + /** + * Returns a sorted array suitable for a dropdown with record types and their translated name + */ + protected function getRecordTypes(): array + { + $types = []; + foreach (SiteTree::page_type_classes() as $class) { + $types[$class] = SiteTree::singleton($class)->i18n_singular_name(); } - asort($pageTypes); - return $pageTypes; + asort($types); + return $types; } public function doSearch(array $data, Form $form): HTTPResponse @@ -1044,7 +1178,7 @@ public function Breadcrumbs($unlinked = false) { $items = ArrayList::create(); - if (($this->getAction() !== 'index') && ($record = $this->currentPage())) { + if (($this->getAction() !== 'index') && ($record = $this->currentRecord())) { // The page is being edited $this->buildEditFormBreadcrumb($items, $record, $unlinked); } else { @@ -1136,8 +1270,21 @@ private function buildListViewBreadcrumb(ArrayList $items, SiteTree $page): void * 'data-hints' attribute of root node of jsTree. * * @return string Serialized JSON + * @deprecated 5.4.0 Use TreeHints() instead. */ public function SiteTreeHints() + { + Deprecation::notice('5.4.0', 'Use TreeHints() instead.'); + return $this->TreeHints(); + } + + /** + * Create serialized JSON string with site tree hints data to be injected into + * 'data-hints' attribute of root node of jsTree. + * + * @return string Serialized JSON + */ + public function TreeHints(): string { $classes = SiteTree::page_type_classes(); $memberID = Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0; @@ -1209,8 +1356,19 @@ public function SiteTreeHints() * which allows the user to change the page type. * * @return SS_List + * @deprecated 5.4.0 use RecordTypes() instead. */ public function PageTypes() + { + Deprecation::notice('5.4.0', 'Use RecordTypes() instead.'); + return $this->RecordTypes(); + } + + /** + * Populates an array of classes in the CMS + * which allows the user to change the record's ClassName field. + */ + public function RecordTypes(): SS_List { $classes = SiteTree::page_type_classes(); @@ -1314,7 +1472,7 @@ public function EditForm($request = null) $this->httpError(400); return null; } - $this->setCurrentPageID($id); + $this->setCurrentRecordID($id); } return $this->getEditForm(); } @@ -1328,7 +1486,7 @@ public function getEditForm($id = null, $fields = null) { // Get record if (!$id) { - $id = $this->currentPageID(); + $id = $this->currentRecordID(); } $record = $this->getRecord($id); @@ -1574,7 +1732,7 @@ public function ViewState($default = 'treeview') /** * Callback to request the list of page types allowed under a given page instance. - * Provides a slower but more precise response over SiteTreeHints + * Provides a slower but more precise response over TreeHints */ public function childfilter(HTTPRequest $request): HTTPResponse { @@ -1671,7 +1829,7 @@ public function ListViewForm() ->setLinkSpec($linkSpec) ->setAttributes(['data-pjax-target' => 'ListViewForm,Breadcrumbs']) ); - $this->setCurrentPageID($parentID); + $this->setCurrentRecordID($parentID); } $gridField = GridField::create('Page', 'Pages', $list, $gridFieldConfig); $gridField->setAttribute('cms-loading-ignore-url-params', true); @@ -1761,6 +1919,13 @@ public function currentPageID() return $id; } + public function currentRecordID(): ?int + { + $id = parent::currentRecordID(); + $this->extend('updateCurrentPageID', $id); + return $id; + } + //------------------------------------------------------------------------------------------// // Data saving handlers @@ -1894,6 +2059,7 @@ public function getNewItem($id, $setID = true) * * @param Versioned|DataObject $record * @return mixed + * @deprecated 5.4.0 Use SilverStripe\Versioned\RecursivePublishable::publishRecursive() instead. */ public function performPublish($record) { @@ -2062,7 +2228,7 @@ public function unpublish(array $data, Form $form): HTTPResponse public function rollback() { return $this->doRollback([ - 'ID' => $this->currentPageID(), + 'ID' => $this->currentRecordID(), 'Version' => $this->getRequest()->param('VersionID') ], null); } @@ -2300,7 +2466,7 @@ protected function getCMSTreeTitle() } /** - * Cache key for SiteTreeHints() method + * Cache key for TreeHints() method * * @param $memberID * @return string diff --git a/code/Controllers/CMSPageAddController.php b/code/Controllers/CMSPageAddController.php index 87a236e85e..8de0237b6c 100644 --- a/code/Controllers/CMSPageAddController.php +++ b/code/Controllers/CMSPageAddController.php @@ -8,6 +8,7 @@ use SilverStripe\Control\HTTPResponse; use SilverStripe\Core\Config\Config; use SilverStripe\Core\Convert; +use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\FieldList; use SilverStripe\Forms\Form; use SilverStripe\Forms\FormAction; @@ -23,6 +24,9 @@ use SilverStripe\Security\Security; use SilverStripe\SiteConfig\SiteConfig; +/** + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Forms\CMSMainAddForm + */ class CMSPageAddController extends CMSPageEditController { @@ -38,6 +42,16 @@ class CMSPageAddController extends CMSPageEditController 'doCancel' ]; + public function __construct() + { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with SilverStripe\CMS\Forms\CMSMainAddForm', + Deprecation::SCOPE_CLASS + ); + parent::__construct(); + } + /** * @return Form */ @@ -134,7 +148,7 @@ public function AddForm() $parentModeField->addExtraClass('parent-mode'); - // CMSMain->currentPageID() automatically sets the homepage, + // CMSMain->currentRecordID() automatically sets the homepage, // which we need to counteract in the default selection (which should default to root, ID=0) if ($parentID = $this->getRequest()->getVar('ParentID')) { $parentModeField->setValue('child'); @@ -220,7 +234,7 @@ public function doAdd(array $data, Form $form): HTTPResponse $editController = CMSPageEditController::singleton(); $editController->setRequest($this->getRequest()); - $editController->setCurrentPageID($record->ID); + $editController->setCurrentRecordID($record->ID); $session = $this->getRequest()->getSession(); $session->set( diff --git a/code/Controllers/CMSPageSettingsController.php b/code/Controllers/CMSPageSettingsController.php index 1450a33387..340131b6ef 100644 --- a/code/Controllers/CMSPageSettingsController.php +++ b/code/Controllers/CMSPageSettingsController.php @@ -17,7 +17,7 @@ class CMSPageSettingsController extends CMSMain public function getEditForm($id = null, $fields = null) { - $record = $this->getRecord($id ?: $this->currentPageID()); + $record = $this->getRecord($id ?: $this->currentRecordID()); return parent::getEditForm($id, ($record) ? $record->getSettingsFields() : null); } diff --git a/code/Controllers/CMSPagesController.php b/code/Controllers/CMSPagesController.php index 9d30509da6..bc73327969 100644 --- a/code/Controllers/CMSPagesController.php +++ b/code/Controllers/CMSPagesController.php @@ -4,11 +4,15 @@ use SilverStripe\CMS\Model\SiteTree; use SilverStripe\Control\Controller; +use SilverStripe\Dev\Deprecation; use SilverStripe\ORM\ArrayList; use SilverStripe\ORM\DataObject; use SilverStripe\View\ArrayData; use stdClass; +/** + * @deprecated 5.4.0 Will be combined back into SilverStripe\CMS\Controllers\CMSMain + */ class CMSPagesController extends CMSMain { @@ -22,6 +26,16 @@ class CMSPagesController extends CMSMain private static $required_permission_codes = 'CMS_ACCESS_CMSMain'; + public function __construct() + { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be combined back into ' . CMSMain::class, + Deprecation::SCOPE_CLASS + ); + parent::__construct(); + } + public function LinkPreview() { return false; diff --git a/code/Controllers/CMSSiteTreeFilter.php b/code/Controllers/CMSSiteTreeFilter.php index d73fe96456..8124967ce8 100644 --- a/code/Controllers/CMSSiteTreeFilter.php +++ b/code/Controllers/CMSSiteTreeFilter.php @@ -7,6 +7,7 @@ use SilverStripe\Core\ClassInfo; use SilverStripe\Core\Convert; use SilverStripe\Core\Injector\Injectable; +use SilverStripe\Dev\Deprecation; use SilverStripe\Forms\DateField; use SilverStripe\ORM\DataList; use SilverStripe\ORM\SS_List; @@ -113,8 +114,12 @@ public function getNumChildrenMethod() return $this->numChildrenMethod; } + /** + * @deprecated 5.4.0 Will be renamed to getRecordClasses() + */ public function getPageClasses($page) { + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be renamed to getRecordClasses()'); if ($this->_cache_ids === null) { $this->populateIDs(); } @@ -178,8 +183,12 @@ protected function populateIDs() } } + /** + * @deprecated 5.4.0 Will be renamed to isRecordIncluded() + */ public function isPageIncluded($page) { + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be renamed to isRecordIncluded()'); if ($this->_cache_ids === null) { $this->populateIDs(); } diff --git a/code/Controllers/LeftAndMainPageIconsExtension.php b/code/Controllers/LeftAndMainPageIconsExtension.php index e962322f06..7b639cf936 100644 --- a/code/Controllers/LeftAndMainPageIconsExtension.php +++ b/code/Controllers/LeftAndMainPageIconsExtension.php @@ -13,22 +13,34 @@ use SilverStripe\Core\Extension; use SilverStripe\Core\Flushable; use SilverStripe\Core\Injector\Injector; +use SilverStripe\Dev\Deprecation; use SilverStripe\View\Requirements; /** * Extension to include custom page icons * * @extends Extension + * @deprecated 5.4.0 Will be renamed to SilverStripe\CMS\Controllers\LeftAndMainRecordIconsExtension */ class LeftAndMainPageIconsExtension extends Extension implements Flushable { + public function __construct() + { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be renamed to SilverStripe\CMS\Controllers\LeftAndMainRecordIconsExtension', + Deprecation::SCOPE_CLASS + ); + parent::__construct(); + } + /** * @throws InvalidArgumentException * @throws ReflectionException */ public function init() { - Requirements::customCSS($this->generatePageIconsCss(), CMSMain::PAGE_ICONS_ID); + Requirements::customCSS($this->generateRecordIconsCss(), CMSMain::CMS_RECORD_ICONS_ID); } /** @@ -39,7 +51,6 @@ public static function flush() Injector::inst()->get(CacheInterface::class . '.SiteTree_PageIcons')->clear(); } - /** * Include CSS for page icons. We're not using the JSTree 'types' option * because it causes too much performance overhead just to add some icons. @@ -47,8 +58,22 @@ public static function flush() * @return string CSS * @throws InvalidArgumentException * @throws ReflectionException + * @deprecated 5.4.0 Use generateRecordIconsCss() instead. */ public function generatePageIconsCss() + { + Deprecation::notice('5.4.0', 'Use generateRecordIconsCss() instead.'); + return $this->generateRecordIconsCss(); + } + + /** + * Include CSS for page icons. We're not using the JSTree 'types' option + * because it causes too much performance overhead just to add some icons. + * + * @throws InvalidArgumentException + * @throws ReflectionException + */ + public function generateRecordIconsCss(): string { /** @var CacheInterface $cache */ $cache = Injector::inst()->get(CacheInterface::class . '.SiteTree_PageIcons'); diff --git a/code/Model/CurrentPageIdentifier.php b/code/Model/CurrentPageIdentifier.php index bee76b8239..0228554577 100644 --- a/code/Model/CurrentPageIdentifier.php +++ b/code/Model/CurrentPageIdentifier.php @@ -6,6 +6,7 @@ /** * This interface lets us set up objects that will tell us what the current page is. + * @deprecated 5.4.0 Will be renamed to SilverStripe\CMS\Model\CurrentRecordIdentifier */ interface CurrentPageIdentifier { @@ -13,6 +14,7 @@ interface CurrentPageIdentifier /** * Get the current page ID. * @return int + * @deprecated 5.4.0 Will be renamed to currentRecordID() */ public function currentPageID(); @@ -20,6 +22,7 @@ public function currentPageID(); * Check if the given DataObject is the current page. * @param DataObject $page The page to check. * @return boolean + * @deprecated 5.4.0 Will be renamed to isCurrentRecord() */ public function isCurrentPage(DataObject $page); } diff --git a/code/Model/RedirectorPage.php b/code/Model/RedirectorPage.php index a79a11bdb2..aa0145b4a1 100644 --- a/code/Model/RedirectorPage.php +++ b/code/Model/RedirectorPage.php @@ -30,6 +30,9 @@ class RedirectorPage extends Page private static string $class_description = 'Redirects requests to another location'; + /** + * @deprecated 5.4.0 Will be renamed to cms_icon_class + */ private static $icon_class = 'font-icon-p-redirect'; private static $show_stage_link = false; diff --git a/code/Model/SiteTree.php b/code/Model/SiteTree.php index c2a109ae41..b96a161ea3 100755 --- a/code/Model/SiteTree.php +++ b/code/Model/SiteTree.php @@ -194,6 +194,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi * * @config * @var array + * @deprecated 5.4.0 Use canCreate() instead. */ private static $need_permission = null; @@ -327,6 +328,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi * @see LeftAndMainPageIconsExtension::generatePageIconsCss() * @config * @var string + * @deprecated 5.4.0 Will be renamed to cms_icon */ private static $icon = null; @@ -334,6 +336,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi * Class attached to page icons in the CMS page tree. Also supports font-icon set. * @config * @var string + * @deprecated 5.4.0 Will be renamed to cms_icon_class */ private static $icon_class = 'font-icon-page'; @@ -565,6 +568,7 @@ public static function get_by_link($link, $cache = true) * Return a subclass map of SiteTree that shouldn't be hidden through {@link SiteTree::$hide_pagetypes} * * @return array + * @deprecated 5.4.0 Will be replaced with updateAllowedSubClasses() */ public static function page_type_classes() { @@ -1022,9 +1026,14 @@ public function getParent() /** * @param CacheInterface $cache * @return $this + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::setCreatableChildrenCache() */ public function setCreatableChildrenCache(CacheInterface $cache) { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with ' . CMSMain::class . '::setCreatableChildrenCache()' + ); $this->creatableChildrenCache = $cache; return $this; @@ -1032,9 +1041,14 @@ public function setCreatableChildrenCache(CacheInterface $cache) /** * @return CacheInterface $cache + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getCreatableChildrenCache() */ public function getCreatableChildrenCache() { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with ' . CMSMain::class . '::getCreatableChildrenCache()' + ); return $this->creatableChildrenCache; } @@ -1399,9 +1413,11 @@ public function getSiteConfig() /** * @return PermissionChecker + * @deprecated 5.4.0 Will be replaced with a non-static method with the same name. */ public static function getPermissionChecker() { + Deprecation::noticeWithNoReplacment('5.4.0', 'Will be replaced with a non-static method with the same name.'); return Injector::inst()->get(PermissionChecker::class.'.sitetree'); } @@ -1801,9 +1817,14 @@ public function flushCache($persistent = true) * Flushes the member specific cache for creatable children * * @param array $memberIDs + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::clearCache() */ public function flushMemberCache($memberIDs = null) { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with ' . CMSMain::class . '::clearCache()' + ); $cache = SiteTree::singleton()->getCreatableChildrenCache(); if (!$memberIDs) { @@ -2844,9 +2865,14 @@ public function allowedChildren() * Gets a list of the page types that can be created under this specific page, including font icons * * @return array + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getCreatableSubClasses() */ public function creatableChildPages() { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with ' . CMSMain::class . '::getCreatableSubClasses()' + ); // Build the list of candidate children $cache = SiteTree::singleton()->getCreatableChildrenCache(); $cacheKey = $this->generateChildrenCacheKey(Security::getCurrentUser() ? Security::getCurrentUser()->ID : 0); @@ -2985,9 +3011,14 @@ public function getStatusFlags($cached = true) * Returns the CSS class used for the page icon in the site tree. * * @return string + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getRecordIconCssClass() */ public function getIconClass() { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with ' . CMSMain::class . '::getRecordIconCssClass()' + ); if ($this->config()->get('icon')) { return ''; } @@ -3223,9 +3254,14 @@ public function plural_name() * Generate link to this page's icon * * @return string + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::getRecordIconUrl() */ public function getPageIconURL() { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with ' . CMSMain::class . '::getRecordIconUrl()' + ); $icon = $this->config()->get('icon'); if (!$icon) { return null; @@ -3352,9 +3388,14 @@ protected function updateDependentPages() * * @param int $memberID * @return string + * @deprecated 5.4.0 Will be replaced with SilverStripe\CMS\Controllers\CMSMain::generateChildrenCacheKey() */ protected function generateChildrenCacheKey($memberID) { + Deprecation::noticeWithNoReplacment( + '5.4.0', + 'Will be replaced with ' . CMSMain::class . '::generateChildrenCacheKey()' + ); return md5($memberID . '_' . __CLASS__); } diff --git a/code/Model/VirtualPage.php b/code/Model/VirtualPage.php index 1d158bf05c..024a83ca51 100644 --- a/code/Model/VirtualPage.php +++ b/code/Model/VirtualPage.php @@ -33,6 +33,9 @@ class VirtualPage extends Page private static string $class_description = 'Displays the content of another page'; + /** + * @deprecated 5.4.0 Will be renamed to cms_icon_class + */ private static $icon_class = 'font-icon-p-virtual'; public static $virtualFields;