DokuWiki

It's better when it's simple

User Tools

Site Tools


Sidebar

Translations of this page?:

Learn about DokuWiki

Advanced Use

Corporate Use

Our Community


Follow us on Facebook, Twitter and other social networks.

Our Privacy Policy

devel:action_router

Action Router

The ActionRouter is the central part that decides what should happen on a request to a Dokuwiki instance based on the action mode.

Action Routing

The ActionRouter uses the do parameter to determine which action to load. Each action has its own class in inc/Action inheriting from AbstractAction or one of it's descendants.

When the router considers running an action, there are several steps (methods) that are called on the Action class. All steps can still abort the action, either because some requirements aren't met or because no further processing is needed within the action. When ever an abortion happens, a different action (usually show, redirect or denied) will be loaded and processing starts again.

  1. check if the action is disabled through disableactions or by the auth backend
    • if yes, shows a message and switches to show or redirect actions for GET and POST request respectively
  2. Action::checkPreconditions
    • The action itself can do custom checks that are required to use this action. An ActionException is to be thrown if permissions aren't met
  3. Action::minimumPermission
    • The action returns the minimum ACL permission needed to execute the action with the current page context. If that minimum is not met, the denied action is loaded
  4. Action::preProcess
    • Any code that should be executed by the action before output is sent to the browser happens here. Processing can still be aborted by throwing an ActionExeption

Once all these steps have been processed, the final action is known and set within the ActionRouter instance.

Output

Once the action has been decided, DokuWiki continues the flow, loads the template and will finally reach a call to tpl_content() which gets the current action from the router and calls Action::tplContent() on it which returns the actual HTML to output.

Note, that not all actions may have a tplContent method, because they either abort to a different action earlier or because they abort the whole further flow and output their own content (think export_html).

Action Plugins

Action Plugin authors do not need to think much about the action router, previous events still work as before.

The ACTION_ACT_PREPROCESS event basically wraps around all the steps under Action Routing. Plugins that prevent the default action in this event's BEFORE phase will then later be handled in the new Plugin action which has a tplContent method that triggers TPL_ACT_UNKNOWN.

devel/action_router.txt · Last modified: 2018-04-25 16:27 by andi