Skip to content

Commit 58a4ae5

Browse files
API Deprecate and update code in preparation for CMS 6 (#3023)
1 parent b779f48 commit 58a4ae5

File tree

4 files changed

+35
-15
lines changed

4 files changed

+35
-15
lines changed

code/Model/RedirectorPage.php

+5
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,13 @@
2323
*/
2424
class RedirectorPage extends Page
2525
{
26+
/**
27+
* @deprecated 5.4.0 use class_description instead.
28+
*/
2629
private static $description = 'Redirects requests to another location';
2730

31+
private static string $class_description = 'Redirects requests to another location';
32+
2833
private static $icon_class = 'font-icon-p-redirect';
2934

3035
private static $show_stage_link = false;

code/Model/SiteTree.php

+22-15
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
136136
* Used as a cache for `SiteTree::allowedChildren()`
137137
* Drastically reduces admin page load when there are a lot of page types
138138
* @var array
139+
* @deprecated 5.4.0 will be moved to SilverStripe\ORM\Hierarchy\Hierarchy->cache_allowedChildren
139140
*/
140141
protected static $_allowedChildren = [];
141142

@@ -419,6 +420,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
419420
*
420421
* @config
421422
* @var string
423+
* @deprecated 5.4.0 use class_description instead.
422424
*/
423425
private static $description = null;
424426

@@ -431,9 +433,15 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
431433
*
432434
* @config
433435
* @var string
436+
* @deprecated 5.4.0 use base_class_description instead.
434437
*/
435438
private static $base_description = 'Generic content page';
436439

440+
/**
441+
* Description for Page and SiteTree classes, but not inherited by subclasses.
442+
*/
443+
private static string $base_class_description = 'Generic content page';
444+
437445
/**
438446
* @var array
439447
*/
@@ -3248,25 +3256,24 @@ public function getPageIconURL()
32483256
*/
32493257
public function classDescription()
32503258
{
3259+
// Ensure base class has an appropriate description if not explicitly set,
3260+
// since we can't set that config for projects.
32513261
$base = in_array(static::class, [Page::class, SiteTree::class]);
32523262
if ($base) {
3253-
return $this->config()->get('base_description');
3263+
$baseDescription = static::config()->get('base_class_description');
3264+
// Fall back to the deprecated config
3265+
if (!$baseDescription) {
3266+
$baseDescription = static::config('base_description');
3267+
}
3268+
return $baseDescription;
32543269
}
3255-
return $this->config()->get('description');
3256-
}
3257-
3258-
/**
3259-
* Get localised description for this page
3260-
*
3261-
* @return string|null
3262-
*/
3263-
public function i18n_classDescription()
3264-
{
3265-
$description = $this->classDescription();
3266-
if ($description) {
3267-
return _t(static::class.'.DESCRIPTION', $description);
3270+
// For all other classes, use the direct class_description config
3271+
$description = parent::classDescription();
3272+
if (!$description) {
3273+
// Fall back to the deprecated config
3274+
$description = static::config()->get('description');
32683275
}
3269-
return null;
3276+
return $description;
32703277
}
32713278

32723279
/**

code/Model/VirtualPage.php

+5
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@
2626
*/
2727
class VirtualPage extends Page
2828
{
29+
/**
30+
* @deprecated 5.4.0 use class_description instead.
31+
*/
2932
private static $description = 'Displays the content of another page';
3033

34+
private static string $class_description = 'Displays the content of another page';
35+
3136
private static $icon_class = 'font-icon-p-virtual';
3237

3338
public static $virtualFields;

lang/en.yml

+3
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ en:
149149
HelpChars: ' Special characters are automatically converted or removed.'
150150
OK: OK
151151
SilverStripe\CMS\Model\RedirectorPage:
152+
CLASS_DESCRIPTION: 'Redirects to an internal page or an external URL'
152153
DESCRIPTION: 'Redirects to an internal page or an external URL'
153154
FILE: File
154155
HEADER: 'This page will redirect users to another page'
@@ -188,6 +189,7 @@ en:
188189
BUTTONSAVEPUBLISH: Publish
189190
BUTTONUNPUBLISH: Unpublish
190191
BUTTONUNPUBLISHDESC: 'Remove this page from the published site'
192+
CLASS_DESCRIPTION: 'Generic content page'
191193
Comments: Comments
192194
Content: Content
193195
DEFAULTABOUTCONTENT: '<p>You can fill this page out with your own content, or delete it and create your own pages.</p>'
@@ -332,6 +334,7 @@ en:
332334
many_many_LinkTracking: 'Link tracking'
333335
SilverStripe\CMS\Model\VirtualPage:
334336
CHOOSE: 'Linked Page'
337+
CLASS_DESCRIPTION: 'Displays the content of another page'
335338
DESCRIPTION: 'Displays the content of another page'
336339
EditLink: edit
337340
HEADER: 'This is a virtual page'

0 commit comments

Comments
 (0)