Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ENH Use class name instead of self #164

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 19 additions & 19 deletions code/SiteConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class SiteConfig extends DataObject implements PermissionProvider, TemplateGloba

public function populateDefaults()
{
$this->Title = _t(self::class . '.SITENAMEDEFAULT', "Your Site Name");
$this->Tagline = _t(self::class . '.TAGLINEDEFAULT', "your tagline here");
$this->Title = _t(SiteConfig::class . '.SITENAMEDEFAULT', "Your Site Name");
$this->Tagline = _t(SiteConfig::class . '.TAGLINEDEFAULT', "your tagline here");

// Allow these defaults to be overridden
parent::populateDefaults();
Expand Down Expand Up @@ -114,17 +114,17 @@ public function getCMSFields()
"Root",
$tabMain = Tab::create(
'Main',
$titleField = TextField::create("Title", _t(self::class . '.SITETITLE', "Site title")),
$titleField = TextField::create("Title", _t(SiteConfig::class . '.SITETITLE', "Site title")),
$taglineField = TextField::create(
"Tagline",
_t(self::class . '.SITETAGLINE', "Site Tagline/Slogan")
_t(SiteConfig::class . '.SITETAGLINE', "Site Tagline/Slogan")
)
),
$tabAccess = Tab::create(
'Access',
$viewersOptionsField = OptionsetField::create(
"CanViewType",
_t(self::class . '.VIEWHEADER', "Who can view pages on this site?")
_t(SiteConfig::class . '.VIEWHEADER', "Who can view pages on this site?")
),
$viewerGroupsField = ListboxField::create(
"ViewerGroups",
Expand All @@ -137,14 +137,14 @@ public function getCMSFields()
),
$viewerMembersField = SearchableMultiDropdownField::create(
"ViewerMembers",
_t(self::class . '.VIEWERMEMBERS', "Viewer Users"),
_t(SiteConfig::class . '.VIEWERMEMBERS', "Viewer Users"),
Member::get()
)
->setIsLazyLoaded(true)
->setUseSearchContext(true),
$editorsOptionsField = OptionsetField::create(
"CanEditType",
_t(self::class . '.EDITHEADER', "Who can edit pages on this site?")
_t(SiteConfig::class . '.EDITHEADER', "Who can edit pages on this site?")
),
$editorGroupsField = ListboxField::create(
"EditorGroups",
Expand All @@ -157,18 +157,18 @@ public function getCMSFields()
),
$editorMembersField = SearchableMultiDropdownField::create(
"EditorMembers",
_t(self::class . '.EDITORMEMBERS', "Editor Users"),
_t(SiteConfig::class . '.EDITORMEMBERS', "Editor Users"),
Member::get(),
)
->setIsLazyLoaded(true)
->setUseSearchContext(true),
$topLevelCreatorsOptionsField = OptionsetField::create(
"CanCreateTopLevelType",
_t(self::class . '.TOPLEVELCREATE', "Who can create pages in the root of the site?")
_t(SiteConfig::class . '.TOPLEVELCREATE', "Who can create pages in the root of the site?")
),
$topLevelCreatorsGroupsField = ListboxField::create(
"CreateTopLevelGroups",
_t(self::class . '.TOPLEVELCREATORGROUPS2', "Top level creator groups")
_t(SiteConfig::class . '.TOPLEVELCREATORGROUPS2', "Top level creator groups")
)
->setSource($groupsMap)
->setAttribute(
Expand All @@ -177,7 +177,7 @@ public function getCMSFields()
),
$topLevelCreatorsMembersField = SearchableMultiDropdownField::create(
"CreateTopLevelMembers",
_t(self::class . '.TOPLEVELCREATORUSERS', "Top level creator users"),
_t(SiteConfig::class . '.TOPLEVELCREATORUSERS', "Top level creator users"),
Member::get()
)
->setIsLazyLoaded(true)
Expand All @@ -198,7 +198,7 @@ public function getCMSFields()
"Only these groups (choose from list)"
);
$viewersOptionsSource[InheritedPermissions::ONLY_THESE_MEMBERS] = _t(
self::class . '.ACCESSONLYTHESEMEMBERS',
SiteConfig::class . '.ACCESSONLYTHESEMEMBERS',
"Only these users (choose from list)"
);
$viewersOptionsField->setSource($viewersOptionsSource);
Expand Down Expand Up @@ -229,7 +229,7 @@ public function getCMSFields()
"Only these groups (choose from list)"
);
$editorsOptionsSource[InheritedPermissions::ONLY_THESE_MEMBERS] = _t(
self::class . '.EDITONLYTHESEMEMBERS',
SiteConfig::class . '.EDITONLYTHESEMEMBERS',
"Only these users (choose from list)"
);
$editorsOptionsField->setSource($editorsOptionsSource);
Expand Down Expand Up @@ -291,8 +291,8 @@ public function getCMSFields()
);
}

$tabMain->setTitle(_t(self::class . '.TABMAIN', "Main"));
$tabAccess->setTitle(_t(self::class . '.TABACCESS', "Access"));
$tabMain->setTitle(_t(SiteConfig::class . '.TABMAIN', "Main"));
$tabAccess->setTitle(_t(SiteConfig::class . '.TABACCESS', "Access"));
$this->extend('updateCMSFields', $fields);

return $fields;
Expand Down Expand Up @@ -341,7 +341,7 @@ public static function current_site_config()
{
$siteConfig = DataObject::get_one(SiteConfig::class);
if (!$siteConfig) {
$siteConfig = self::make_site_config();
$siteConfig = SiteConfig::make_site_config();
}

static::singleton()->extend('updateCurrentSiteConfig', $siteConfig);
Expand All @@ -359,7 +359,7 @@ public function requireDefaultRecords()
$config = DataObject::get_one(SiteConfig::class);

if (!$config) {
self::make_site_config();
SiteConfig::make_site_config();

DB::alteration_message("Added default site config", "created");
}
Expand Down Expand Up @@ -514,13 +514,13 @@ public function providePermissions()
{
return [
'EDIT_SITECONFIG' => [
'name' => _t(self::class . '.EDIT_PERMISSION', 'Manage site configuration'),
'name' => _t(SiteConfig::class . '.EDIT_PERMISSION', 'Manage site configuration'),
'category' => _t(
'SilverStripe\\Security\\Permission.PERMISSIONS_CATEGORY',
'Roles and access permissions'
),
'help' => _t(
self::class . '.EDIT_PERMISSION_HELP',
SiteConfig::class . '.EDIT_PERMISSION_HELP',
'Ability to edit global access settings/top-level page permissions.'
),
'sort' => 400
Expand Down
Loading