mirror of
https://github.com/silverstripe/silverstripe-cms
synced 2024-10-22 08:05:56 +02:00
ENH Replace E_USER_ERROR errors with exceptions
This commit is contained in:
parent
3ea2190565
commit
d17f058622
@ -396,11 +396,11 @@ class CMSPageHistoryController extends CMSMain
|
||||
$toVersionRecord = Versioned::get_version(SiteTree::class, $id, $toVersion);
|
||||
|
||||
if (!$fromVersionRecord) {
|
||||
user_error("Can't find version $fromVersion of page $id", E_USER_ERROR);
|
||||
throw new \Exception("Can't find version $fromVersion of page $id");
|
||||
}
|
||||
|
||||
if (!$toVersionRecord) {
|
||||
user_error("Can't find version $toVersion of page $id", E_USER_ERROR);
|
||||
throw new \Exception("Can't find version $toVersion of page $id");
|
||||
}
|
||||
|
||||
if (!$record) {
|
||||
|
@ -96,7 +96,7 @@ in the other stage:<br />
|
||||
|
||||
$fields->push(new HeaderField(
|
||||
'Header',
|
||||
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.HEADER', 'Remove all orphaned pages task')
|
||||
_t(__CLASS__ . '.HEADER', 'Remove all orphaned pages task')
|
||||
));
|
||||
$fields->push(new LiteralField(
|
||||
'Description',
|
||||
@ -134,14 +134,14 @@ in the other stage:<br />
|
||||
'SelectAllLiteral',
|
||||
sprintf(
|
||||
'<p><a href="#" onclick="javascript:jQuery(\'#Form_Form_OrphanIDs :checkbox\').attr(\'checked\', \'checked\'); return false;">%s</a> ',
|
||||
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.SELECTALL', 'select all')
|
||||
_t(__CLASS__ . '.SELECTALL', 'select all')
|
||||
)
|
||||
));
|
||||
$fields->push(new LiteralField(
|
||||
'UnselectAllLiteral',
|
||||
sprintf(
|
||||
'<a href="#" onclick="javascript:jQuery(\'#Form_Form_OrphanIDs :checkbox\').attr(\'checked\', \'\'); return false;">%s</a></p>',
|
||||
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.UNSELECTALL', 'unselect all')
|
||||
_t(__CLASS__ . '.UNSELECTALL', 'unselect all')
|
||||
)
|
||||
));
|
||||
$fields->push(new OptionsetField(
|
||||
@ -149,13 +149,13 @@ in the other stage:<br />
|
||||
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.CHOOSEOPERATION', 'Choose operation:'),
|
||||
[
|
||||
'rebase' => _t(
|
||||
'SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.OPERATION_REBASE',
|
||||
__CLASS__ . '.OPERATION_REBASE',
|
||||
sprintf(
|
||||
'Rebase selected to a new holder page "%s" and unpublish. None of these pages will show up for website visitors.',
|
||||
$this->rebaseHolderTitle()
|
||||
)
|
||||
),
|
||||
'remove' => _t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.OPERATION_REMOVE', 'Remove selected from all stages (WARNING: Will destroy all selected pages from both stage and live)'),
|
||||
'remove' => _t(__CLASS__ . '.OPERATION_REMOVE', 'Remove selected from all stages (WARNING: Will destroy all selected pages from both stage and live)'),
|
||||
],
|
||||
'rebase'
|
||||
));
|
||||
@ -164,7 +164,7 @@ in the other stage:<br />
|
||||
sprintf(
|
||||
'<p class="message">%s</p>',
|
||||
_t(
|
||||
'SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.DELETEWARNING',
|
||||
__CLASS__ . '.DELETEWARNING',
|
||||
'Warning: These operations are not reversible. Please handle with care.'
|
||||
)
|
||||
)
|
||||
@ -174,7 +174,7 @@ in the other stage:<br />
|
||||
'NotFoundLabel',
|
||||
sprintf(
|
||||
'<p class="message">%s</p>',
|
||||
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.NONEFOUND', 'No orphans found')
|
||||
_t(__CLASS__ . '.NONEFOUND', 'No orphans found')
|
||||
)
|
||||
));
|
||||
}
|
||||
@ -184,7 +184,7 @@ in the other stage:<br />
|
||||
'SilverStripe\\Forms\\Form',
|
||||
$fields,
|
||||
new FieldList(
|
||||
new FormAction('doSubmit', _t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.BUTTONRUN', 'Run'))
|
||||
new FormAction('doSubmit', _t(__CLASS__ . '.BUTTONRUN', 'Run'))
|
||||
)
|
||||
);
|
||||
|
||||
@ -217,7 +217,7 @@ in the other stage:<br />
|
||||
$successIDs = $this->rebaseOrphans($data['OrphanIDs']);
|
||||
break;
|
||||
default:
|
||||
user_error(sprintf("Unknown operation: '%s'", $data['OrphanOperation']), E_USER_ERROR);
|
||||
throw new \InvalidArgumentException(sprintf("Unknown operation: '%s'", $data['OrphanOperation']));
|
||||
}
|
||||
|
||||
$content = '';
|
||||
@ -228,7 +228,7 @@ in the other stage:<br />
|
||||
}
|
||||
$content .= "</ul>";
|
||||
} else {
|
||||
$content = _t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.NONEREMOVED', 'None removed');
|
||||
$content = _t(__CLASS__ . '.NONEREMOVED', 'None removed');
|
||||
}
|
||||
|
||||
return $this->customise([
|
||||
|
Loading…
Reference in New Issue
Block a user