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);
|
$toVersionRecord = Versioned::get_version(SiteTree::class, $id, $toVersion);
|
||||||
|
|
||||||
if (!$fromVersionRecord) {
|
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) {
|
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) {
|
if (!$record) {
|
||||||
|
@ -96,7 +96,7 @@ in the other stage:<br />
|
|||||||
|
|
||||||
$fields->push(new HeaderField(
|
$fields->push(new HeaderField(
|
||||||
'Header',
|
'Header',
|
||||||
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.HEADER', 'Remove all orphaned pages task')
|
_t(__CLASS__ . '.HEADER', 'Remove all orphaned pages task')
|
||||||
));
|
));
|
||||||
$fields->push(new LiteralField(
|
$fields->push(new LiteralField(
|
||||||
'Description',
|
'Description',
|
||||||
@ -134,14 +134,14 @@ in the other stage:<br />
|
|||||||
'SelectAllLiteral',
|
'SelectAllLiteral',
|
||||||
sprintf(
|
sprintf(
|
||||||
'<p><a href="#" onclick="javascript:jQuery(\'#Form_Form_OrphanIDs :checkbox\').attr(\'checked\', \'checked\'); return false;">%s</a> ',
|
'<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(
|
$fields->push(new LiteralField(
|
||||||
'UnselectAllLiteral',
|
'UnselectAllLiteral',
|
||||||
sprintf(
|
sprintf(
|
||||||
'<a href="#" onclick="javascript:jQuery(\'#Form_Form_OrphanIDs :checkbox\').attr(\'checked\', \'\'); return false;">%s</a></p>',
|
'<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(
|
$fields->push(new OptionsetField(
|
||||||
@ -149,13 +149,13 @@ in the other stage:<br />
|
|||||||
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.CHOOSEOPERATION', 'Choose operation:'),
|
_t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.CHOOSEOPERATION', 'Choose operation:'),
|
||||||
[
|
[
|
||||||
'rebase' => _t(
|
'rebase' => _t(
|
||||||
'SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.OPERATION_REBASE',
|
__CLASS__ . '.OPERATION_REBASE',
|
||||||
sprintf(
|
sprintf(
|
||||||
'Rebase selected to a new holder page "%s" and unpublish. None of these pages will show up for website visitors.',
|
'Rebase selected to a new holder page "%s" and unpublish. None of these pages will show up for website visitors.',
|
||||||
$this->rebaseHolderTitle()
|
$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'
|
'rebase'
|
||||||
));
|
));
|
||||||
@ -164,7 +164,7 @@ in the other stage:<br />
|
|||||||
sprintf(
|
sprintf(
|
||||||
'<p class="message">%s</p>',
|
'<p class="message">%s</p>',
|
||||||
_t(
|
_t(
|
||||||
'SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.DELETEWARNING',
|
__CLASS__ . '.DELETEWARNING',
|
||||||
'Warning: These operations are not reversible. Please handle with care.'
|
'Warning: These operations are not reversible. Please handle with care.'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@ -174,7 +174,7 @@ in the other stage:<br />
|
|||||||
'NotFoundLabel',
|
'NotFoundLabel',
|
||||||
sprintf(
|
sprintf(
|
||||||
'<p class="message">%s</p>',
|
'<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',
|
'SilverStripe\\Forms\\Form',
|
||||||
$fields,
|
$fields,
|
||||||
new FieldList(
|
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']);
|
$successIDs = $this->rebaseOrphans($data['OrphanIDs']);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
user_error(sprintf("Unknown operation: '%s'", $data['OrphanOperation']), E_USER_ERROR);
|
throw new \InvalidArgumentException(sprintf("Unknown operation: '%s'", $data['OrphanOperation']));
|
||||||
}
|
}
|
||||||
|
|
||||||
$content = '';
|
$content = '';
|
||||||
@ -228,7 +228,7 @@ in the other stage:<br />
|
|||||||
}
|
}
|
||||||
$content .= "</ul>";
|
$content .= "</ul>";
|
||||||
} else {
|
} else {
|
||||||
$content = _t('SilverStripe\\CMS\\Tasks\\RemoveOrphanedPagesTask.NONEREMOVED', 'None removed');
|
$content = _t(__CLASS__ . '.NONEREMOVED', 'None removed');
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->customise([
|
return $this->customise([
|
||||||
|
Loading…
Reference in New Issue
Block a user