-
Notifications
You must be signed in to change notification settings - Fork 24
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
API Use the new SingleRecordAdmin class #179
base: 6
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,12 +2,9 @@ | |
|
||
namespace SilverStripe\SiteConfig; | ||
|
||
use SilverStripe\CMS\Model\SiteTree; | ||
use SilverStripe\Forms\FieldList; | ||
use SilverStripe\Forms\FormAction; | ||
use SilverStripe\Forms\HiddenField; | ||
use SilverStripe\Forms\ListboxField; | ||
use SilverStripe\Forms\LiteralField; | ||
use SilverStripe\Forms\OptionsetField; | ||
use SilverStripe\Forms\Tab; | ||
use SilverStripe\Forms\TabSet; | ||
|
@@ -21,7 +18,6 @@ | |
use SilverStripe\Security\PermissionProvider; | ||
use SilverStripe\Security\Security; | ||
use SilverStripe\View\TemplateGlobalProvider; | ||
use SilverStripe\CMS\Controllers\CMSMain; | ||
use SilverStripe\Forms\SearchableMultiDropdownField; | ||
use SilverStripe\Security\InheritedPermissions; | ||
|
||
|
@@ -284,31 +280,6 @@ public function getCMSFields() | |
return $fields; | ||
} | ||
|
||
/** | ||
* Get the actions that are sent to the CMS. | ||
* | ||
* In your extensions: updateEditFormActions($actions) | ||
* | ||
* @return FieldList | ||
*/ | ||
public function getCMSActions() | ||
{ | ||
if (Permission::check('ADMIN') || Permission::check('EDIT_SITECONFIG')) { | ||
$actions = FieldList::create( | ||
FormAction::create( | ||
'save_siteconfig', | ||
_t('SilverStripe\\CMS\\Controllers\\CMSMain.SAVE', 'Save') | ||
)->addExtraClass('btn-primary font-icon-save') | ||
); | ||
} else { | ||
$actions = FieldList::create(); | ||
} | ||
|
||
$this->extend('updateCMSActions', $actions); | ||
|
||
return $actions; | ||
} | ||
|
||
public function CMSEditLink(): ?string | ||
{ | ||
return SiteConfigLeftAndMain::singleton()->Link(); | ||
|
@@ -317,18 +288,13 @@ public function CMSEditLink(): ?string | |
/** | ||
* Get the current sites SiteConfig, and creates a new one through | ||
* {@link make_site_config()} if none is found. | ||
* | ||
* @return SiteConfig | ||
*/ | ||
public static function current_site_config() | ||
public static function current_site_config(): SiteConfig | ||
{ | ||
$siteConfig = DataObject::get_one(SiteConfig::class); | ||
if (!$siteConfig) { | ||
$siteConfig = SiteConfig::make_site_config(); | ||
} | ||
|
||
static::singleton()->extend('updateCurrentSiteConfig', $siteConfig); | ||
|
||
Comment on lines
-329
to
-331
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removing this because we no longer call I've checked and nothing in core or supported modules (including fluent and subsites) uses this hook (and according to GitHub nor does anything else in the universe) and I also checked with our in-house development teams who weren't able to find any usage of it in their private repositories either. Seems perfectly safe to remove - but I'll mention it in the changelog to be cover our bases. |
||
return $siteConfig; | ||
} | ||
|
||
|
@@ -490,6 +456,15 @@ public function canEdit($member = null) | |
return Permission::checkMember($member, "EDIT_SITECONFIG"); | ||
} | ||
|
||
public function canDelete($member = null) | ||
{ | ||
$extended = $this->extendedCan(__FUNCTION__, $member); | ||
if ($extended !== null) { | ||
return $extended; | ||
} | ||
return false; | ||
} | ||
Comment on lines
+459
to
+466
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Needed to prevent a delete button from being presented to admin users. No one should be able to delete |
||
|
||
/** | ||
* @return array | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let the admin handle the actions.
LeftAndMain
automatically adds asave
action.This method exists on
DataObject
so we don't need to deprecate this.