ENH Use class name instead of self

This commit is contained in:
Steve Boyd 2024-06-17 14:51:54 +12:00
parent 88ae614cfc
commit ea38c43ea5
10 changed files with 73 additions and 73 deletions

View File

@ -105,7 +105,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
private static $tree_class = SiteTree::class; private static $tree_class = SiteTree::class;
private static $session_namespace = self::class; private static $session_namespace = CMSMain::class;
private static $required_permission_codes = 'CMS_ACCESS_CMSMain'; private static $required_permission_codes = 'CMS_ACCESS_CMSMain';
@ -587,7 +587,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// Render using full-subtree template // Render using full-subtree template
return $markingSet->renderChildren( return $markingSet->renderChildren(
[ self::class . '_SubTree', 'type' => 'Includes' ], [ CMSMain::class . '_SubTree', 'type' => 'Includes' ],
$this->getTreeNodeCustomisations() $this->getTreeNodeCustomisations()
); );
} }
@ -607,7 +607,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
'rootTitle' => $rootTitle, 'rootTitle' => $rootTitle,
'extraClass' => $this->getTreeNodeClasses($node), 'extraClass' => $this->getTreeNodeClasses($node),
'Title' => _t( 'Title' => _t(
self::class . '.PAGETYPE_TITLE', CMSMain::class . '.PAGETYPE_TITLE',
'(Page type: {type}) {title}', '(Page type: {type}) {title}',
[ [
'type' => $node->i18n_singular_name(), 'type' => $node->i18n_singular_name(),
@ -718,7 +718,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr
// Render using single node template // Render using single node template
$html = $markingSet->renderChildren( $html = $markingSet->renderChildren(
[ self::class . '_TreeNode', 'type' => 'Includes'], [ CMSMain::class . '_TreeNode', 'type' => 'Includes'],
$this->getTreeNodeCustomisations() $this->getTreeNodeCustomisations()
); );

View File

@ -133,6 +133,6 @@ class ModelAsController extends Controller implements NestedController
Debug::message("Using record #$sitetree->ID of type " . get_class($sitetree) . " with link {$sitetree->Link()}"); Debug::message("Using record #$sitetree->ID of type " . get_class($sitetree) . " with link {$sitetree->Link()}");
} }
return self::controller_for($sitetree, $this->getRequest()->param('Action')); return ModelAsController::controller_for($sitetree, $this->getRequest()->param('Action'));
} }
} }

View File

@ -30,9 +30,9 @@ class OldPageRedirector extends Extension
$getvars = $request->getVars(); $getvars = $request->getVars();
unset($getvars['url']); unset($getvars['url']);
$page = self::find_old_page($params, 0); $page = OldPageRedirector::find_old_page($params, 0);
if (!$page) { if (!$page) {
$page = self::find_old_page($params); $page = OldPageRedirector::find_old_page($params);
} }
$cleanPage = trim(Director::makeRelative($page) ?? '', '/'); $cleanPage = trim(Director::makeRelative($page) ?? '', '/');
if (!$cleanPage) { if (!$cleanPage) {
@ -95,7 +95,7 @@ class OldPageRedirector extends Extension
if ($page && $page->canView()) { if ($page && $page->canView()) {
if (count($params ?? [])) { if (count($params ?? [])) {
// We have to go deeper! // We have to go deeper!
$ret = self::find_old_page($params, $page, $redirect); $ret = OldPageRedirector::find_old_page($params, $page, $redirect);
if ($ret) { if ($ret) {
// A valid child page was found! We can return it // A valid child page was found! We can return it
return $ret; return $ret;

View File

@ -39,12 +39,12 @@ class RootURLController extends Controller implements Resettable
*/ */
public static function get_homepage_link() public static function get_homepage_link()
{ {
if (!self::$cached_homepage_link) { if (!RootURLController::$cached_homepage_link) {
$link = Config::inst()->get(__CLASS__, 'default_homepage_link'); $link = Config::inst()->get(__CLASS__, 'default_homepage_link');
singleton(__CLASS__)->extend('updateHomepageLink', $link); singleton(__CLASS__)->extend('updateHomepageLink', $link);
self::$cached_homepage_link = $link; RootURLController::$cached_homepage_link = $link;
} }
return self::$cached_homepage_link; return RootURLController::$cached_homepage_link;
} }
/** /**
@ -56,7 +56,7 @@ class RootURLController extends Controller implements Resettable
*/ */
public static function should_be_on_root(SiteTree $page) public static function should_be_on_root(SiteTree $page)
{ {
return (!self::$is_at_root && self::get_homepage_link() == trim($page->RelativeLink(true) ?? '', '/')); return (!RootURLController::$is_at_root && RootURLController::get_homepage_link() == trim($page->RelativeLink(true) ?? '', '/'));
} }
/** /**
@ -64,14 +64,14 @@ class RootURLController extends Controller implements Resettable
*/ */
public static function reset() public static function reset()
{ {
self::$cached_homepage_link = null; RootURLController::$cached_homepage_link = null;
} }
protected function beforeHandleRequest(HTTPRequest $request) protected function beforeHandleRequest(HTTPRequest $request)
{ {
parent::beforeHandleRequest($request); parent::beforeHandleRequest($request);
self::$is_at_root = true; RootURLController::$is_at_root = true;
if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) { if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
$this->getResponse()->redirect(Controller::join_links( $this->getResponse()->redirect(Controller::join_links(
@ -86,7 +86,7 @@ class RootURLController extends Controller implements Resettable
public function handleRequest(HTTPRequest $request): HTTPResponse public function handleRequest(HTTPRequest $request): HTTPResponse
{ {
self::$is_at_root = true; RootURLController::$is_at_root = true;
$this->beforeHandleRequest($request); $this->beforeHandleRequest($request);
if (!$this->getResponse()->isFinished()) { if (!$this->getResponse()->isFinished()) {
@ -95,7 +95,7 @@ class RootURLController extends Controller implements Resettable
return $this->getResponse(); return $this->getResponse();
} }
$request->setUrl(self::get_homepage_link() . '/'); $request->setUrl(RootURLController::get_homepage_link() . '/');
$request->match('$URLSegment//$Action', true); $request->match('$URLSegment//$Action', true);
$controller = new ModelAsController(); $controller = new ModelAsController();

View File

@ -48,7 +48,7 @@ class LinkablePlugin implements ModelQueryPlugin
*/ */
public function getIdentifier(): string public function getIdentifier(): string
{ {
return self::IDENTIFIER; return LinkablePlugin::IDENTIFIER;
} }
/** /**

View File

@ -128,11 +128,11 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
* @var array * @var array
*/ */
private static $allowed_children = [ private static $allowed_children = [
self::class SiteTree::class
]; ];
/** /**
* Used as a cache for `self::allowedChildren()` * Used as a cache for `SiteTree::allowedChildren()`
* Drastically reduces admin page load when there are a lot of page types * Drastically reduces admin page load when there are a lot of page types
* @var array * @var array
*/ */
@ -457,7 +457,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
public static function get_by_link($link, $cache = true) public static function get_by_link($link, $cache = true)
{ {
// Compute the column names with dynamic a dynamic table name // Compute the column names with dynamic a dynamic table name
$tableName = DataObject::singleton(self::class)->baseTable(); $tableName = DataObject::singleton(SiteTree::class)->baseTable();
$urlSegmentExpr = sprintf('"%s"."URLSegment"', $tableName); $urlSegmentExpr = sprintf('"%s"."URLSegment"', $tableName);
$parentIDExpr = sprintf('"%s"."ParentID"', $tableName); $parentIDExpr = sprintf('"%s"."ParentID"', $tableName);
@ -471,16 +471,16 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
// Grab the initial root level page to traverse down from. // Grab the initial root level page to traverse down from.
$URLSegment = array_shift($parts); $URLSegment = array_shift($parts);
$conditions = [$urlSegmentExpr => rawurlencode($URLSegment ?? '')]; $conditions = [$urlSegmentExpr => rawurlencode($URLSegment ?? '')];
if (self::config()->get('nested_urls')) { if (static::config()->get('nested_urls')) {
$conditions[] = [$parentIDExpr => 0]; $conditions[] = [$parentIDExpr => 0];
} }
/** @var SiteTree $sitetree */ /** @var SiteTree $sitetree */
$sitetree = DataObject::get_one(self::class, $conditions, $cache); $sitetree = DataObject::get_one(SiteTree::class, $conditions, $cache);
/// Fall back on a unique URLSegment for b/c. /// Fall back on a unique URLSegment for b/c.
if (!$sitetree if (!$sitetree
&& self::config()->get('nested_urls') && static::config()->get('nested_urls')
&& $sitetree = DataObject::get_one(self::class, [ && $sitetree = DataObject::get_one(SiteTree::class, [
$urlSegmentExpr => $URLSegment $urlSegmentExpr => $URLSegment
], $cache) ], $cache)
) { ) {
@ -489,7 +489,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
// Attempt to grab an alternative page from extensions. // Attempt to grab an alternative page from extensions.
if (!$sitetree) { if (!$sitetree) {
$parentID = self::config()->get('nested_urls') ? 0 : null; $parentID = static::config()->get('nested_urls') ? 0 : null;
if ($alternatives = static::singleton()->extend('alternateGetByLink', $URLSegment, $parentID)) { if ($alternatives = static::singleton()->extend('alternateGetByLink', $URLSegment, $parentID)) {
foreach ($alternatives as $alternative) { foreach ($alternatives as $alternative) {
@ -505,14 +505,14 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
} }
// Check if we have any more URL parts to parse. // Check if we have any more URL parts to parse.
if (!self::config()->get('nested_urls') || !count($parts ?? [])) { if (!static::config()->get('nested_urls') || !count($parts ?? [])) {
return $sitetree; return $sitetree;
} }
// Traverse down the remaining URL segments and grab the relevant SiteTree objects. // Traverse down the remaining URL segments and grab the relevant SiteTree objects.
foreach ($parts as $segment) { foreach ($parts as $segment) {
$next = DataObject::get_one( $next = DataObject::get_one(
self::class, SiteTree::class,
[ [
$urlSegmentExpr => $segment, $urlSegmentExpr => $segment,
$parentIDExpr => $sitetree->ID $parentIDExpr => $sitetree->ID
@ -552,12 +552,12 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{ {
$classes = ClassInfo::getValidSubClasses(); $classes = ClassInfo::getValidSubClasses();
$baseClassIndex = array_search(self::class, $classes ?? []); $baseClassIndex = array_search(SiteTree::class, $classes ?? []);
if ($baseClassIndex !== false) { if ($baseClassIndex !== false) {
unset($classes[$baseClassIndex]); unset($classes[$baseClassIndex]);
} }
$kill_ancestors = self::config()->get('hide_pagetypes', Config::UNINHERITED) ?? []; $kill_ancestors = SiteTree::config()->get('hide_pagetypes', Config::UNINHERITED) ?? [];
// figure out if there are any classes we don't want to appear // figure out if there are any classes we don't want to appear
foreach ($classes as $class) { foreach ($classes as $class) {
@ -601,8 +601,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
} }
/** @var SiteTree $page */ /** @var SiteTree $page */
if (!($page = DataObject::get_by_id(self::class, $arguments['id'])) // Get the current page by ID. if (!($page = DataObject::get_by_id(SiteTree::class, $arguments['id'])) // Get the current page by ID.
&& !($page = Versioned::get_latest_version(self::class, $arguments['id'])) // Attempt link to old version. && !($page = Versioned::get_latest_version(SiteTree::class, $arguments['id'])) // Attempt link to old version.
) { ) {
return null; // There were no suitable matches at all. return null; // There were no suitable matches at all.
} }
@ -681,11 +681,11 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
public function RelativeLink($action = null) public function RelativeLink($action = null)
{ {
if ($this->ParentID && self::config()->get('nested_urls')) { if ($this->ParentID && static::config()->get('nested_urls')) {
$parent = $this->Parent(); $parent = $this->Parent();
// If page is removed select parent from version history (for archive page view) // If page is removed select parent from version history (for archive page view)
if ((!$parent || !$parent->exists()) && !$this->isOnDraft()) { if ((!$parent || !$parent->exists()) && !$this->isOnDraft()) {
$parent = Versioned::get_latest_version(self::class, $this->ParentID); $parent = Versioned::get_latest_version(SiteTree::class, $this->ParentID);
} }
$base = $parent ? $parent->RelativeLink($this->URLSegment) : null; $base = $parent ? $parent->RelativeLink($this->URLSegment) : null;
} elseif (!$action && $this->URLSegment == RootURLController::get_homepage_link()) { } elseif (!$action && $this->URLSegment == RootURLController::get_homepage_link()) {
@ -722,7 +722,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
Versioned::set_stage(Versioned::LIVE); Versioned::set_stage(Versioned::LIVE);
$tablename = $this->baseTable(); $tablename = $this->baseTable();
/** @var SiteTree $live */ /** @var SiteTree $live */
$live = Versioned::get_one_by_stage(self::class, Versioned::LIVE, [ $live = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, [
"\"$tablename\".\"ID\"" => $this->ID "\"$tablename\".\"ID\"" => $this->ID
]); ]);
if ($live) { if ($live) {
@ -996,7 +996,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{ {
$parentID = $this->getField("ParentID"); $parentID = $this->getField("ParentID");
if ($parentID) { if ($parentID) {
return SiteTree::get_by_id(self::class, $parentID); return SiteTree::get_by_id(SiteTree::class, $parentID);
} }
return null; return null;
} }
@ -1502,11 +1502,11 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
private function getGenerator(): string private function getGenerator(): string
{ {
$generator = trim(Config::inst()->get(self::class, 'meta_generator') ?? ''); $generator = trim(Config::inst()->get(SiteTree::class, 'meta_generator') ?? '');
if ($generator === '') { if ($generator === '') {
return ''; return '';
} }
if (self::config()->get('show_meta_generator_version')) { if (static::config()->get('show_meta_generator_version')) {
$version = $this->getVersionProvider()->getModuleVersion('silverstripe/framework'); $version = $this->getVersionProvider()->getModuleVersion('silverstripe/framework');
// Only include stable version numbers so as not to clutter any aggregate reports // Only include stable version numbers so as not to clutter any aggregate reports
// with non-standard versions e.g. forks // with non-standard versions e.g. forks
@ -1594,7 +1594,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
parent::requireDefaultRecords(); parent::requireDefaultRecords();
// default pages // default pages
if (static::class === self::class && $this->config()->get('create_default_pages')) { if (static::class === SiteTree::class && $this->config()->get('create_default_pages')) {
$defaultHomepage = RootURLController::config()->get('default_homepage_link'); $defaultHomepage = RootURLController::config()->get('default_homepage_link');
if (!SiteTree::get_by_link($defaultHomepage)) { if (!SiteTree::get_by_link($defaultHomepage)) {
$homepage = new Page(); $homepage = new Page();
@ -1863,7 +1863,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
public function validURLSegment() public function validURLSegment()
{ {
// Check known urlsegment blacklists // Check known urlsegment blacklists
if (self::config()->get('nested_urls') && $this->ParentID) { if (static::config()->get('nested_urls') && $this->ParentID) {
// Guard against url segments for sub-pages // Guard against url segments for sub-pages
$parent = $this->Parent(); $parent = $this->Parent();
if ($controller = ModelAsController::controller_for($parent)) { if ($controller = ModelAsController::controller_for($parent)) {
@ -1893,7 +1893,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
if ($this->ID) { if ($this->ID) {
$source = $source->exclude('ID', $this->ID); $source = $source->exclude('ID', $this->ID);
} }
if (self::config()->get('nested_urls')) { if (static::config()->get('nested_urls')) {
$source = $source->filter('ParentID', $this->ParentID ? $this->ParentID : 0); $source = $source->filter('ParentID', $this->ParentID ? $this->ParentID : 0);
} }
return !$source->exists(); return !$source->exists();
@ -1935,7 +1935,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{ {
$tablename = $this->baseTable(); $tablename = $this->baseTable();
/** @var SiteTree $stageRecord */ /** @var SiteTree $stageRecord */
$stageRecord = Versioned::get_one_by_stage(self::class, Versioned::DRAFT, [ $stageRecord = Versioned::get_one_by_stage(SiteTree::class, Versioned::DRAFT, [
"\"$tablename\".\"ID\"" => $this->ID "\"$tablename\".\"ID\"" => $this->ID
]); ]);
return ($stageRecord) ? $stageRecord->URLSegment : null; return ($stageRecord) ? $stageRecord->URLSegment : null;
@ -1950,7 +1950,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{ {
$tablename = $this->baseTable(); $tablename = $this->baseTable();
/** @var SiteTree $liveRecord */ /** @var SiteTree $liveRecord */
$liveRecord = Versioned::get_one_by_stage(self::class, Versioned::LIVE, [ $liveRecord = Versioned::get_one_by_stage(SiteTree::class, Versioned::LIVE, [
"\"$tablename\".\"ID\"" => $this->ID "\"$tablename\".\"ID\"" => $this->ID
]); ]);
return ($liveRecord) ? $liveRecord->URLSegment : null; return ($liveRecord) ? $liveRecord->URLSegment : null;
@ -2124,7 +2124,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
$baseLink = Controller::join_links( $baseLink = Controller::join_links(
Director::absoluteBaseURL(), Director::absoluteBaseURL(),
(self::config()->get('nested_urls') && $this->ParentID ? $this->Parent()->RelativeLink(true) : null) (static::config()->get('nested_urls') && $this->ParentID ? $this->Parent()->RelativeLink(true) : null)
); );
$urlsegment = SiteTreeURLSegmentField::create("URLSegment", $this->fieldLabel('URLSegment')) $urlsegment = SiteTreeURLSegmentField::create("URLSegment", $this->fieldLabel('URLSegment'))
@ -2136,7 +2136,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
['pagetype' => $this->i18n_singular_name()] ['pagetype' => $this->i18n_singular_name()]
))) )))
->addExtraClass(($this->isHomePage() ? 'homepage-warning' : '')); ->addExtraClass(($this->isHomePage() ? 'homepage-warning' : ''));
$helpText = (self::config()->get('nested_urls') && $this->numChildren()) $helpText = (static::config()->get('nested_urls') && $this->numChildren())
? $this->fieldLabel('LinkChangeNote') ? $this->fieldLabel('LinkChangeNote')
: ''; : '';
if (!URLSegmentFilter::create()->getAllowMultibyte()) { if (!URLSegmentFilter::create()->getAllowMultibyte()) {
@ -2223,7 +2223,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
), 'Title'); ), 'Title');
} }
if (self::$runCMSFieldsExtensions) { if (SiteTree::$runCMSFieldsExtensions) {
$this->extend('updateCMSFields', $fields); $this->extend('updateCMSFields', $fields);
} }
@ -2266,7 +2266,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
"root" => _t("SilverStripe\\CMS\\Model\\SiteTree.PARENTTYPE_ROOT", "Top-level page"), "root" => _t("SilverStripe\\CMS\\Model\\SiteTree.PARENTTYPE_ROOT", "Top-level page"),
"subpage" => _t("SilverStripe\\CMS\\Model\\SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"), "subpage" => _t("SilverStripe\\CMS\\Model\\SiteTree.PARENTTYPE_SUBPAGE", "Sub-page underneath a parent page"),
]), ]),
$parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), self::class, 'ID', 'MenuTitle') $parentIDField = new TreeDropdownField("ParentID", $this->fieldLabel('ParentID'), SiteTree::class, 'ID', 'MenuTitle')
))->setTitle(_t("SilverStripe\\CMS\\Model\\SiteTree.PAGELOCATION", "Page location")), ))->setTitle(_t("SilverStripe\\CMS\\Model\\SiteTree.PAGELOCATION", "Page location")),
$visibility = new FieldGroup( $visibility = new FieldGroup(
new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')), new CheckboxField("ShowInMenus", $this->fieldLabel('ShowInMenus')),
@ -2397,7 +2397,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
} }
} }
if (self::$runCMSFieldsExtensions) { if (SiteTree::$runCMSFieldsExtensions) {
$this->extend('updateSettingsFields', $fields); $this->extend('updateSettingsFields', $fields);
} }
@ -2411,7 +2411,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
public function fieldLabels($includerelations = true) public function fieldLabels($includerelations = true)
{ {
$cacheKey = static::class . '_' . $includerelations; $cacheKey = static::class . '_' . $includerelations;
if (!isset(self::$_cache_field_labels[$cacheKey])) { if (!isset(SiteTree::$_cache_field_labels[$cacheKey])) {
$labels = parent::fieldLabels($includerelations); $labels = parent::fieldLabels($includerelations);
$labels['Title'] = _t(__CLASS__.'.PAGETITLE', "Page name"); $labels['Title'] = _t(__CLASS__.'.PAGETITLE', "Page name");
$labels['MenuTitle'] = _t(__CLASS__.'.MENUTITLE', "Navigation label"); $labels['MenuTitle'] = _t(__CLASS__.'.MENUTITLE', "Navigation label");
@ -2442,10 +2442,10 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
$labels['BackLinkTracking'] = _t(__CLASS__.'.many_many_BackLinkTracking', 'Backlink Tracking'); $labels['BackLinkTracking'] = _t(__CLASS__.'.many_many_BackLinkTracking', 'Backlink Tracking');
} }
self::$_cache_field_labels[$cacheKey] = $labels; SiteTree::$_cache_field_labels[$cacheKey] = $labels;
} }
return self::$_cache_field_labels[$cacheKey]; return SiteTree::$_cache_field_labels[$cacheKey];
} }
/** /**
@ -2487,8 +2487,8 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
$rootTabSet->addExtraClass('ss-ui-action-tabset action-menus noborder'); $rootTabSet->addExtraClass('ss-ui-action-tabset action-menus noborder');
// Render page information into the "more-options" drop-up, on the top. // Render page information into the "more-options" drop-up, on the top.
$liveRecord = Versioned::get_by_stage(self::class, Versioned::LIVE)->byID($this->ID); $liveRecord = Versioned::get_by_stage(SiteTree::class, Versioned::LIVE)->byID($this->ID);
$infoTemplate = SSViewer::get_templates_by_class(static::class, '_Information', self::class); $infoTemplate = SSViewer::get_templates_by_class(static::class, '_Information', SiteTree::class);
$moreOptions->push( $moreOptions->push(
new LiteralField( new LiteralField(
'Information', 'Information',
@ -2642,7 +2642,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{ {
// Use an alias to get the updates made by $this->publish // Use an alias to get the updates made by $this->publish
/** @var SiteTree $stageSelf */ /** @var SiteTree $stageSelf */
$stageSelf = Versioned::get_by_stage(self::class, Versioned::DRAFT)->byID($this->ID); $stageSelf = Versioned::get_by_stage(SiteTree::class, Versioned::DRAFT)->byID($this->ID);
$stageSelf->writeWithoutVersion(); $stageSelf->writeWithoutVersion();
// Need to update pages linking to this one as no longer broken // Need to update pages linking to this one as no longer broken
@ -2663,7 +2663,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
{ {
if ($parentID = $this->ParentID) { if ($parentID = $this->ParentID) {
/** @var SiteTree $parentPage */ /** @var SiteTree $parentPage */
$parentPage = Versioned::get_latest_version(self::class, $parentID); $parentPage = Versioned::get_latest_version(SiteTree::class, $parentID);
if (!$parentPage || !$parentPage->isOnDraft()) { if (!$parentPage || !$parentPage->isOnDraft()) {
return true; return true;
} }
@ -2690,7 +2690,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
// Need to update pages linking to this one as no longer broken // Need to update pages linking to this one as no longer broken
/** @var SiteTree $result */ /** @var SiteTree $result */
$result = Versioned::get_by_stage(self::class, Versioned::DRAFT) $result = Versioned::get_by_stage(SiteTree::class, Versioned::DRAFT)
->byID($this->ID); ->byID($this->ID);
$result->updateDependentPages(); $result->updateDependentPages();
@ -2730,7 +2730,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
protected function getClassDropdown() protected function getClassDropdown()
{ {
$classes = self::page_type_classes(); $classes = SiteTree::page_type_classes();
$currentClass = null; $currentClass = null;
$result = []; $result = [];
@ -3129,7 +3129,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
public static function disableCMSFieldsExtensions() public static function disableCMSFieldsExtensions()
{ {
self::$runCMSFieldsExtensions = false; SiteTree::$runCMSFieldsExtensions = false;
} }
/** /**
@ -3138,7 +3138,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
public static function enableCMSFieldsExtensions() public static function enableCMSFieldsExtensions()
{ {
self::$runCMSFieldsExtensions = true; SiteTree::$runCMSFieldsExtensions = true;
} }
public function providePermissions() public function providePermissions()
@ -3184,7 +3184,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
public function singular_name() public function singular_name()
{ {
$base = in_array(static::class, [Page::class, self::class]); $base = in_array(static::class, [Page::class, SiteTree::class]);
if ($base) { if ($base) {
return $this->config()->get('base_singular_name'); return $this->config()->get('base_singular_name');
} }
@ -3198,7 +3198,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
public function plural_name() public function plural_name()
{ {
$base = in_array(static::class, [Page::class, self::class]); $base = in_array(static::class, [Page::class, SiteTree::class]);
if ($base) { if ($base) {
return $this->config()->get('base_plural_name'); return $this->config()->get('base_plural_name');
} }
@ -3242,7 +3242,7 @@ class SiteTree extends DataObject implements PermissionProvider, i18nEntityProvi
*/ */
public function classDescription() public function classDescription()
{ {
$base = in_array(static::class, [Page::class, self::class]); $base = in_array(static::class, [Page::class, SiteTree::class]);
if ($base) { if ($base) {
return $this->config()->get('base_description'); return $this->config()->get('base_description');
} }

View File

@ -34,7 +34,7 @@ class VirtualPage extends Page
/** /**
* @var array Define fields that are not virtual - the virtual page must define these fields themselves. * @var array Define fields that are not virtual - the virtual page must define these fields themselves.
* Note that anything in {@link self::config()->initially_copied_fields} is implicitly included in this list. * Note that anything in {@link static::config()->initially_copied_fields} is implicitly included in this list.
*/ */
private static $non_virtual_fields = [ private static $non_virtual_fields = [
"ID", "ID",
@ -107,7 +107,7 @@ class VirtualPage extends Page
*/ */
public function getNonVirtualisedFields() public function getNonVirtualisedFields()
{ {
$config = self::config(); $config = static::config();
return array_merge( return array_merge(
$config->get('non_virtual_fields'), $config->get('non_virtual_fields'),
$config->get('initially_copied_fields') $config->get('initially_copied_fields')
@ -219,7 +219,7 @@ class VirtualPage extends Page
// Setup the linking to the original page. // Setup the linking to the original page.
$copyContentFromField = TreeDropdownField::create( $copyContentFromField = TreeDropdownField::create(
'CopyContentFromID', 'CopyContentFromID',
_t(self::class . '.CHOOSE', "Linked Page"), _t(VirtualPage::class . '.CHOOSE', "Linked Page"),
SiteTree::class SiteTree::class
); );
@ -248,10 +248,10 @@ class VirtualPage extends Page
'class' => 'cmsEditlink', 'class' => 'cmsEditlink',
'href' => $this->CopyContentFrom()->CMSEditLink(), 'href' => $this->CopyContentFrom()->CMSEditLink(),
], ],
_t(self::class . '.EditLink', 'edit') _t(VirtualPage::class . '.EditLink', 'edit')
); );
$msgs[] = _t( $msgs[] = _t(
self::class . '.HEADERWITHLINK', VirtualPage::class . '.HEADERWITHLINK',
"This is a virtual page copying content from \"{title}\" ({link})", "This is a virtual page copying content from \"{title}\" ({link})",
[ [
'title' => $this->CopyContentFrom()->obj('Title'), 'title' => $this->CopyContentFrom()->obj('Title'),
@ -259,7 +259,7 @@ class VirtualPage extends Page
] ]
); );
} else { } else {
$msgs[] = _t(self::class . '.HEADER', "This is a virtual page"); $msgs[] = _t(VirtualPage::class . '.HEADER', "This is a virtual page");
$msgs[] = _t( $msgs[] = _t(
'SilverStripe\\CMS\\Model\\SiteTree.VIRTUALPAGEWARNING', 'SilverStripe\\CMS\\Model\\SiteTree.VIRTUALPAGEWARNING',
'Please choose a linked page and save first in order to publish this page' 'Please choose a linked page and save first in order to publish this page'
@ -305,7 +305,7 @@ class VirtualPage extends Page
// We also want to copy certain, but only if we're copying the source page for the first // We also want to copy certain, but only if we're copying the source page for the first
// time. After this point, the user is free to customise these for the virtual page themselves. // time. After this point, the user is free to customise these for the virtual page themselves.
if ($this->isChanged('CopyContentFromID', 2) && $this->CopyContentFromID) { if ($this->isChanged('CopyContentFromID', 2) && $this->CopyContentFromID) {
foreach (self::config()->get('initially_copied_fields') as $fieldName) { foreach (static::config()->get('initially_copied_fields') as $fieldName) {
$this->$fieldName = $source->$fieldName; $this->$fieldName = $source->$fieldName;
} }
} }
@ -347,7 +347,7 @@ class VirtualPage extends Page
if ($orig && $orig->exists() && !$orig->config()->get('can_be_root') && !$this->ParentID) { if ($orig && $orig->exists() && !$orig->config()->get('can_be_root') && !$this->ParentID) {
$result->addError( $result->addError(
_t( _t(
self::class . '.PageTypNotAllowedOnRoot', VirtualPage::class . '.PageTypNotAllowedOnRoot',
'Original page type "{type}" is not allowed on the root level for this virtual page', 'Original page type "{type}" is not allowed on the root level for this virtual page',
['type' => $orig->i18n_singular_name()] ['type' => $orig->i18n_singular_name()]
), ),

View File

@ -16,7 +16,7 @@ class CMSMainTest_ClassA extends SiteTree implements TestOnly
{ {
parent::onBeforeWrite(); parent::onBeforeWrite();
if ($this->ClassName !== self::class) { if ($this->ClassName !== CMSMainTest_ClassA::class) {
throw new ValidationException("Class saved with incorrect ClassName"); throw new ValidationException("Class saved with incorrect ClassName");
} }
} }

View File

@ -14,7 +14,7 @@ class CMSMainTest_ClassB extends SiteTree implements TestOnly
{ {
parent::onBeforeWrite(); parent::onBeforeWrite();
if ($this->ClassName !== self::class) { if ($this->ClassName !== CMSMainTest_ClassB::class) {
throw new ValidationException("Class saved with incorrect ClassName"); throw new ValidationException("Class saved with incorrect ClassName");
} }
} }

View File

@ -27,8 +27,8 @@ class CmsReportsTest extends SapphireTest
parent::setUp(); parent::setUp();
// set the dates by hand: impossible to set via yml // set the dates by hand: impossible to set via yml
$afterThreshold = strtotime('-' . (self::$daysAgo - 1) . ' days', strtotime('31-06-2009 00:00:00')); $afterThreshold = strtotime('-' . (CmsReportsTest::$daysAgo - 1) . ' days', strtotime('31-06-2009 00:00:00'));
$beforeThreshold = strtotime('-' . (self::$daysAgo + 1) . ' days', strtotime('31-06-2009 00:00:00')); $beforeThreshold = strtotime('-' . (CmsReportsTest::$daysAgo + 1) . ' days', strtotime('31-06-2009 00:00:00'));
$after = $this->objFromFixture(SiteTree::class, 'after'); $after = $this->objFromFixture(SiteTree::class, 'after');
$before = $this->objFromFixture(SiteTree::class, 'before'); $before = $this->objFromFixture(SiteTree::class, 'before');