@@ -116,17 +116,22 @@ class DataObject extends ModelData implements DataObjectInterface, i18nEntityPro
116
116
{
117
117
/**
118
118
* Human-readable singular name.
119
- * @var string
120
- * @config
121
119
*/
122
- private static $ singular_name = null ;
120
+ private static ? string $ singular_name = null ;
123
121
124
122
/**
125
123
* Human-readable plural name
126
- * @var string
127
- * @config
128
124
*/
129
- private static $ plural_name = null ;
125
+ private static ?string $ plural_name = null ;
126
+
127
+ /**
128
+ * Description of the class.
129
+ * Unlike most configuration, this is usually used uninherited, meaning it should be defined
130
+ * on each subclass.
131
+ *
132
+ * Used in some areas of the CMS, e.g. when selecting what type of record to create.
133
+ */
134
+ private static ?string $ class_description = null ;
130
135
131
136
/**
132
137
* @config
@@ -141,7 +146,6 @@ class DataObject extends ModelData implements DataObjectInterface, i18nEntityPro
141
146
* @var string
142
147
*/
143
148
private static $ default_classname = null ;
144
-
145
149
/**
146
150
* Whether this DataObject class must only use the primary database and not a read-only replica
147
151
* Note that this will be only be enforced when using DataQuery::execute() or
@@ -946,6 +950,27 @@ public function i18n_plural_name()
946
950
return _t (static ::class . '.PLURALNAME ' , $ this ->plural_name ());
947
951
}
948
952
953
+ /**
954
+ * Get description for this class
955
+ */
956
+ public function classDescription (): ?string
957
+ {
958
+ return static ::config ()->get ('class_description ' , Config::UNINHERITED );
959
+ }
960
+
961
+ /**
962
+ * Get localised description for this class
963
+ */
964
+ public function i18nClassDescription (): ?string
965
+ {
966
+ $ placeholder = 'PLACEHOLDER_DESCRIPTION ' ;
967
+ $ description = _t (static ::class.'.CLASS_DESCRIPTION ' , $ this ->classDescription () ?? $ placeholder );
968
+ if ($ description === $ placeholder ) {
969
+ return null ;
970
+ }
971
+ return $ description ;
972
+ }
973
+
949
974
/**
950
975
* Standard implementation of a title/label for a specific
951
976
* record. Tries to find properties 'Title' or 'Name',
@@ -3515,14 +3540,11 @@ public static function get_one($callerClass = null, $filter = "", $cache = true,
3515
3540
}
3516
3541
3517
3542
/**
3518
- * Flush the cached results for all relations (has_one, has_many, many_many)
3519
- * Also clears any cached aggregate data.
3543
+ * @inheritDoc
3520
3544
*
3521
- * @param boolean $persistent When true will also clear persistent data stored in the Cache system.
3522
- * When false will just clear session-local cached data
3523
- * @return static $this
3545
+ * Also flush the cached results for all relations (has_one, has_many, many_many)
3524
3546
*/
3525
- public function flushCache ($ persistent = true )
3547
+ public function flushCache (bool $ persistent = true ): static
3526
3548
{
3527
3549
if (static ::class == DataObject::class) {
3528
3550
DataObject::$ _cache_get_one = [];
@@ -3536,11 +3558,9 @@ public function flushCache($persistent = true)
3536
3558
}
3537
3559
}
3538
3560
3539
- $ this ->extend ('onFlushCache ' );
3540
-
3541
3561
$ this ->components = [];
3542
3562
$ this ->eagerLoadedData = [];
3543
- return $ this ;
3563
+ return parent :: flushCache ( $ persistent ) ;
3544
3564
}
3545
3565
3546
3566
/**
@@ -3567,7 +3587,7 @@ public static function flush_and_destroy_cache()
3567
3587
*/
3568
3588
public static function reset ()
3569
3589
{
3570
- DBEnum::flushCache ();
3590
+ DBEnum::clearStaticCache ();
3571
3591
ClassInfo::reset_db_cache ();
3572
3592
static ::getSchema ()->reset ();
3573
3593
DataObject::$ _cache_get_one = [];
0 commit comments