Skip to content

Commit

Permalink
ENH Use class name instead of self
Browse files Browse the repository at this point in the history
  • Loading branch information
emteknetnz committed Jun 5, 2024
1 parent 5e1706e commit 67a2fce
Show file tree
Hide file tree
Showing 10 changed files with 73 additions and 73 deletions.
8 changes: 4 additions & 4 deletions code/Controllers/CMSMain.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ class CMSMain extends LeftAndMain implements CurrentPageIdentifier, PermissionPr

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';

Expand Down Expand Up @@ -587,7 +587,7 @@ public function getSiteTreeFor(

// Render using full-subtree template
return $markingSet->renderChildren(
[ self::class . '_SubTree', 'type' => 'Includes' ],
[ CMSMain::class . '_SubTree', 'type' => 'Includes' ],
$this->getTreeNodeCustomisations()
);
}
Expand All @@ -607,7 +607,7 @@ protected function getTreeNodeCustomisations()
'rootTitle' => $rootTitle,
'extraClass' => $this->getTreeNodeClasses($node),
'Title' => _t(
self::class . '.PAGETYPE_TITLE',
CMSMain::class . '.PAGETYPE_TITLE',
'(Page type: {type}) {title}',
[
'type' => $node->i18n_singular_name(),
Expand Down Expand Up @@ -718,7 +718,7 @@ public function updatetreenodes(HTTPRequest $request): HTTPResponse

// Render using single node template
$html = $markingSet->renderChildren(
[ self::class . '_TreeNode', 'type' => 'Includes'],
[ CMSMain::class . '_TreeNode', 'type' => 'Includes'],
$this->getTreeNodeCustomisations()
);

Expand Down
2 changes: 1 addition & 1 deletion code/Controllers/ModelAsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,6 @@ public function getNestedController(): ContentController
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'));
}
}
6 changes: 3 additions & 3 deletions code/Controllers/OldPageRedirector.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public function onBeforeHTTPError404(HTTPRequest $request)
$getvars = $request->getVars();
unset($getvars['url']);

$page = self::find_old_page($params, 0);
$page = OldPageRedirector::find_old_page($params, 0);
if (!$page) {
$page = self::find_old_page($params);
$page = OldPageRedirector::find_old_page($params);
}
$cleanPage = trim(Director::makeRelative($page) ?? '', '/');
if (!$cleanPage) {
Expand Down Expand Up @@ -95,7 +95,7 @@ public static function find_old_page($params, $parent = null, $redirect = false)
if ($page && $page->canView()) {
if (count($params ?? [])) {
// We have to go deeper!
$ret = self::find_old_page($params, $page, $redirect);
$ret = OldPageRedirector::find_old_page($params, $page, $redirect);
if ($ret) {
// A valid child page was found! We can return it
return $ret;
Expand Down
16 changes: 8 additions & 8 deletions code/Controllers/RootURLController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ class RootURLController extends Controller implements Resettable
*/
public static function get_homepage_link()
{
if (!self::$cached_homepage_link) {
if (!RootURLController::$cached_homepage_link) {
$link = Config::inst()->get(__CLASS__, 'default_homepage_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;
}

/**
Expand All @@ -56,22 +56,22 @@ public static function get_homepage_link()
*/
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) ?? '', '/'));
}

/**
* Resets the cached homepage link value - useful for testing.
*/
public static function reset()
{
self::$cached_homepage_link = null;
RootURLController::$cached_homepage_link = null;
}

protected function beforeHandleRequest(HTTPRequest $request)
{
parent::beforeHandleRequest($request);

self::$is_at_root = true;
RootURLController::$is_at_root = true;

if (!DB::is_active() || !ClassInfo::hasTable('SiteTree')) {
$this->getResponse()->redirect(Controller::join_links(
Expand All @@ -86,7 +86,7 @@ protected function beforeHandleRequest(HTTPRequest $request)

public function handleRequest(HTTPRequest $request): HTTPResponse
{
self::$is_at_root = true;
RootURLController::$is_at_root = true;
$this->beforeHandleRequest($request);

if (!$this->getResponse()->isFinished()) {
Expand All @@ -95,7 +95,7 @@ public function handleRequest(HTTPRequest $request): HTTPResponse
return $this->getResponse();
}

$request->setUrl(self::get_homepage_link() . '/');
$request->setUrl(RootURLController::get_homepage_link() . '/');
$request->match('$URLSegment//$Action', true);
$controller = new ModelAsController();

Expand Down
2 changes: 1 addition & 1 deletion code/GraphQL/LinkablePlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class LinkablePlugin implements ModelQueryPlugin
*/
public function getIdentifier(): string
{
return self::IDENTIFIER;
return LinkablePlugin::IDENTIFIER;
}

/**
Expand Down
Loading

0 comments on commit 67a2fce

Please sign in to comment.