diff --git a/code/AdminRootController.php b/code/AdminRootController.php index bad63473c..32fade435 100644 --- a/code/AdminRootController.php +++ b/code/AdminRootController.php @@ -41,7 +41,7 @@ public static function get_admin_route() */ public static function admin_url(string $action = '') { - return Controller::join_links(self::get_admin_route(), $action); + return Controller::join_links(AdminRootController::get_admin_route(), $action); } /** @@ -69,18 +69,18 @@ public static function admin_url(string $action = '') */ public static function rules() { - if (self::$adminRules === null) { - self::$adminRules = []; + if (AdminRootController::$adminRules === null) { + AdminRootController::$adminRules = []; // Map over the array calling add_rule_for_controller on each $classes = CMSMenu::get_cms_classes(null, true, CMSMenu::URL_PRIORITY); array_map([__CLASS__, 'add_rule_for_controller'], $classes ?? []); } - return self::$adminRules; + return AdminRootController::$adminRules; } /** - * Add the appropriate k/v pair to self::$rules for the given controller. + * Add the appropriate k/v pair to AdminRootController::$rules for the given controller. * * @param string $controllerClass Name of class */ @@ -98,8 +98,8 @@ protected static function add_rule_for_controller($controllerClass) $rule = $urlSegment . '//' . $urlRule; // ensure that the first call to add_rule_for_controller for a rule takes precedence - if (!isset(self::$adminRules[$rule])) { - self::$adminRules[$rule] = $controllerClass; + if (!isset(AdminRootController::$adminRules[$rule])) { + AdminRootController::$adminRules[$rule] = $controllerClass; } } } @@ -111,12 +111,12 @@ public function handleRequest(HTTPRequest $request): HTTPResponse $segment = Config::forClass($this->config()->get('default_panel')) ->get('url_segment'); - $this->redirect(Controller::join_links(self::admin_url(), $segment, '/')); + $this->redirect(Controller::join_links(AdminRootController::admin_url(), $segment, '/')); return $this->getResponse(); } // Otherwise - $rules = self::rules(); + $rules = AdminRootController::rules(); foreach ($rules as $pattern => $controller) { if (($arguments = $request->match($pattern, true)) !== false) { /** @var LeftAndMain $controllerObj */ diff --git a/code/CMSMenu.php b/code/CMSMenu.php index 20b00163e..0318dda0a 100644 --- a/code/CMSMenu.php +++ b/code/CMSMenu.php @@ -63,7 +63,7 @@ class CMSMenu implements IteratorAggregate, i18nEntityProvider */ public static function populate_menu() { - self::$menu_is_cleared = false; + CMSMenu::$menu_is_cleared = false; } /** @@ -73,9 +73,9 @@ public static function populate_menu() */ public static function add_controller($controllerClass) { - if ($menuItem = self::menuitem_for_controller($controllerClass)) { + if ($menuItem = CMSMenu::menuitem_for_controller($controllerClass)) { $code = static::get_menu_code($controllerClass); - self::add_menu_item_obj($code, $menuItem); + CMSMenu::add_menu_item_obj($code, $menuItem); } } @@ -123,7 +123,7 @@ protected static function menuitem_for_controller($controllerClass) */ public static function add_link($code, $menuTitle, $url, $priority = -1, $attributes = null, $iconClass = null) { - return self::add_menu_item($code, $menuTitle, $url, null, $priority, $attributes, $iconClass); + return CMSMenu::add_menu_item($code, $menuTitle, $url, null, $priority, $attributes, $iconClass); } /** @@ -155,10 +155,10 @@ public static function add_menu_item( ) { // If a class is defined, then force the use of that as a code. This helps prevent menu item duplication if ($controllerClass) { - $code = self::get_menu_code($controllerClass); + $code = CMSMenu::get_menu_code($controllerClass); } - return self::replace_menu_item( + return CMSMenu::replace_menu_item( $code, $menuTitle, $url, @@ -177,7 +177,7 @@ public static function add_menu_item( */ public static function get_menu_item($code) { - $menuItems = self::get_menu_items(); + $menuItems = CMSMenu::get_menu_items(); return (isset($menuItems[$code])) ? $menuItems[$code] : false; } @@ -202,11 +202,11 @@ public static function get_menu_items() $menuItems = []; // Set up default menu items - if (!self::$menu_is_cleared) { - $cmsClasses = self::get_cms_classes(); + if (!CMSMenu::$menu_is_cleared) { + $cmsClasses = CMSMenu::get_cms_classes(); foreach ($cmsClasses as $cmsClass) { - $menuItem = self::menuitem_for_controller($cmsClass); - $menuCode = self::get_menu_code($cmsClass); + $menuItem = CMSMenu::menuitem_for_controller($cmsClass); + $menuCode = CMSMenu::get_menu_code($cmsClass); if ($menuItem) { $menuItems[$menuCode] = $menuItem; } @@ -214,7 +214,7 @@ public static function get_menu_items() } // Apply changes - foreach (self::$menu_item_changes as $change) { + foreach (CMSMenu::$menu_item_changes as $change) { switch ($change['type']) { case 'add': $menuItems[$change['code']] = $change['item']; @@ -255,7 +255,7 @@ public static function get_viewable_menu_items($member = null) } $viewableMenuItems = []; - $allMenuItems = self::get_menu_items(); + $allMenuItems = CMSMenu::get_menu_items(); if ($allMenuItems) { foreach ($allMenuItems as $code => $menuItem) { // exclude all items which have a controller to perform permission @@ -286,7 +286,7 @@ public static function get_viewable_menu_items($member = null) */ public static function remove_menu_item($code) { - self::$menu_item_changes[] = ['type' => 'remove', 'code' => $code]; + CMSMenu::$menu_item_changes[] = ['type' => 'remove', 'code' => $code]; } /** @@ -296,8 +296,8 @@ public static function remove_menu_item($code) */ public static function remove_menu_class($className) { - $code = self::get_menu_code($className); - self::remove_menu_item($code); + $code = CMSMenu::get_menu_code($className); + CMSMenu::remove_menu_item($code); } /** @@ -305,8 +305,8 @@ public static function remove_menu_class($className) */ public static function clear_menu() { - self::$menu_item_changes = []; - self::$menu_is_cleared = true; + CMSMenu::$menu_item_changes = []; + CMSMenu::$menu_is_cleared = true; } /** @@ -341,7 +341,7 @@ public static function replace_menu_item( $item->setAttributes($attributes); } - self::$menu_item_changes[] = [ + CMSMenu::$menu_item_changes[] = [ 'type' => 'add', 'code' => $code, 'item' => $item, @@ -356,7 +356,7 @@ public static function replace_menu_item( */ protected static function add_menu_item_obj($code, $cmsMenuItem) { - self::$menu_item_changes[] = [ + CMSMenu::$menu_item_changes[] = [ 'type' => 'add', 'code' => $code, 'item' => $cmsMenuItem, @@ -374,7 +374,7 @@ protected static function add_menu_item_obj($code, $cmsMenuItem) * @param string $sort Name of config on which to sort. Can be 'menu_priority' or 'url_priority' * @return array Valid, unique subclasses */ - public static function get_cms_classes($root = null, $recursive = true, $sort = self::MENU_PRIORITY) + public static function get_cms_classes($root = null, $recursive = true, $sort = CMSMenu::MENU_PRIORITY) { if (!$root) { $root = LeftAndMain::class; @@ -415,7 +415,7 @@ public static function get_cms_classes($root = null, $recursive = true, $sort = */ public function getIterator(): Traversable { - return new ArrayIterator(self::get_menu_items()); + return new ArrayIterator(CMSMenu::get_menu_items()); } /** @@ -423,7 +423,7 @@ public function getIterator(): Traversable */ public function provideI18nEntities() { - $cmsClasses = self::get_cms_classes(); + $cmsClasses = CMSMenu::get_cms_classes(); $entities = []; foreach ($cmsClasses as $cmsClass) { $defaultTitle = LeftAndMain::menu_title($cmsClass, false); diff --git a/code/LeftAndMain.php b/code/LeftAndMain.php index 0af467cf4..edefe9ac9 100644 --- a/code/LeftAndMain.php +++ b/code/LeftAndMain.php @@ -597,7 +597,7 @@ public static function getRequiredPermissions() { $class = get_called_class(); // If the user is accessing LeftAndMain directly, only generic permissions are required. - if ($class === self::class) { + if ($class === LeftAndMain::class) { return 'CMS_ACCESS'; } $code = Config::inst()->get($class, 'required_permission_codes'); @@ -814,7 +814,7 @@ public function afterHandleRequest() $errorCode = $this->response->getStatusCode(); $errorType = $this->response->getStatusDescription(); $defaultMessage = _t( - self::class . '.ErrorMessage', + LeftAndMain::class . '.ErrorMessage', 'Sorry, it seems there was a {errorcode} error.', ['errorcode' => $errorCode] ); @@ -825,7 +825,7 @@ public function afterHandleRequest() 'ErrorType' => $errorType, 'Message' => DBField::create_field( 'HTMLFragment', - _t(self::class . '.ErrorMessage' . $errorCode, $defaultMessage) + _t(LeftAndMain::class . '.ErrorMessage' . $errorCode, $defaultMessage) ), ]), ]), $errorCode, $errorType); @@ -2067,7 +2067,7 @@ public function getHttpErrorMessage(): string * Called by {@link LeftAndMainErrorExtension} * @internal */ - public function setHttpErrorMessage(string $message): self + public function setHttpErrorMessage(string $message): LeftAndMain { $this->httpErrorMessage = $message; return $this; diff --git a/code/ModelAdmin.php b/code/ModelAdmin.php index 5af2b9c1c..228d8c293 100644 --- a/code/ModelAdmin.php +++ b/code/ModelAdmin.php @@ -141,7 +141,7 @@ abstract class ModelAdmin extends LeftAndMain * * Sets the `modelClass` field which determines which of the {@link DataObject} objects will have visible data. This * is determined by the URL (with the first slug being the name of the DataObject class to represent. If this class - * is loaded without any URL, we pick the first DataObject from the list of {@link self::$managed_models}. + * is loaded without any URL, we pick the first DataObject from the list of {@link ModelAdmin::$managed_models}. */ protected function init() { @@ -247,7 +247,7 @@ public function getCMSEditLinkForManagedDataObject(DataObject $obj): string /** * Produces an edit form that includes a default {@link \SilverStripe\Forms\GridField\GridField} for the currently * active {@link \SilverStripe\ORM\DataObject}. The GridField will show data from the currently active `modelClass` - * only (see {@link self::init()}). + * only (see {@link ModelAdmin::init()}). * * @param int|null $id * @param \SilverStripe\Forms\FieldList $fields @@ -534,8 +534,8 @@ public function isManagedModel(string $modelClassOrModelTab): bool } /** - * Returns all importers defined in {@link self::$model_importers}. - * If none are defined, we fall back to {@link self::managed_models} + * Returns all importers defined in {@link ModelAdmin::$model_importers}. + * If none are defined, we fall back to {@link ModelAdmin::managed_models} * with a default {@link CsvBulkLoader} class. In this case the column names of the first row * in the CSV file are assumed to have direct mappings to properties on the object. * @@ -645,7 +645,7 @@ public function ImportForm() /** * Imports the submitted CSV file based on specifications given in - * {@link self::model_importers}. + * {@link ModelAdmin::model_importers}. * Redirects back with a success/failure message. */ public function import(array $data, Form $form): HTTPResponse diff --git a/tests/php/Navigator/SilverStripeNavigatorTest_TestItem.php b/tests/php/Navigator/SilverStripeNavigatorTest_TestItem.php index ba788b8df..d1a523b33 100644 --- a/tests/php/Navigator/SilverStripeNavigatorTest_TestItem.php +++ b/tests/php/Navigator/SilverStripeNavigatorTest_TestItem.php @@ -9,7 +9,7 @@ class SilverStripeNavigatorTest_TestItem extends SilverStripeNavigatorItem imple { public function getTitle() { - return self::class; + return SilverStripeNavigatorTest_TestItem::class; } public function getHTML()