Skip to content
Snippets Groups Projects
Commit 81f9e22b authored by Andreas Gohr's avatar Andreas Gohr
Browse files

allow actions to throw exception that are shown to the user

parent 0f9e19d9
No related branches found
No related tags found
No related merge requests found
...@@ -15,8 +15,12 @@ namespace dokuwiki\Action\Exception; ...@@ -15,8 +15,12 @@ namespace dokuwiki\Action\Exception;
*/ */
class ActionException extends \Exception { class ActionException extends \Exception {
/** @var string the new action */
protected $newaction; protected $newaction;
/** @var bool should the exception's message be shown to the user? */
protected $displayToUser = false;
/** /**
* ActionException constructor. * ActionException constructor.
* *
...@@ -36,4 +40,15 @@ class ActionException extends \Exception { ...@@ -36,4 +40,15 @@ class ActionException extends \Exception {
public function getNewAction() { public function getNewAction() {
return $this->newaction; return $this->newaction;
} }
/**
* Should this Exception's message be shown to the user?
*
* @param null|bool $set when null is given, the current setting is not changed
* @return bool
*/
public function displayToUser($set = null) {
if(!is_null($set)) $this->displayToUser = $set;
return $set;
}
} }
...@@ -88,6 +88,11 @@ class ActionRouter { ...@@ -88,6 +88,11 @@ class ActionRouter {
msg('Action disabled: ' . hsc($presetup), -1); msg('Action disabled: ' . hsc($presetup), -1);
} }
// some actions may request the display of a message
if($e->displayToUser()) {
msg(hsc($e->getMessage()), -1);
}
// do setup for new action // do setup for new action
$this->transitionAction($presetup, $actionname); $this->transitionAction($presetup, $actionname);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment