.

CommandsBaseController Class Reference
[Controller]

Installs a generic post handler at url /process_commands. More...

Inheritance diagram for CommandsBaseController:
ControllerBase IController IEventSink

List of all members.

Public Member Functions

  action_commands_post ($page_data)
  Find according commands and redirect.
  get_routes ()
  Return array of IDispatchToken this controller takes responsability.

Detailed Description

Installs a generic post handler at url /process_commands.

The list form controller processes one command taken from the POST array. A command is recognized by starting with "cmd_" and usually is a submit button.

A command has a form of cmd_[type]_[action]_[params]. For example a command to disable a user can be named "cmd_user_disable_5", where 5 is the ID of the user. You need to install a handler on the user controller, to process this command, though.

Controllers can install themselves as handlers by registering sub-urls, like for example /process_commands/user. If a command is recognized, the second parameter is interpreted as type and everything is forwarded to an url like

 https://process_commands/[type]/[action]/[params]

If you are interested in handling a command, you must create a matching route. Given the above example of disableing a user, this would be:

 ... new CommandsRoute('https://process_commands/users/{id:ui>}/disable', $this, 'users_disable')
Attention:
Note the route is of type CommandsRoute, which extends ParameterizedRoute. This is extremly important, since it implements protection against Cross Site Request Forgery. You may alternatively add a CommandsRouteRenderDecorator to a custom route to achieve the same effect.
Author:
Gerd Riesselmann

Definition at line 37 of file commands.basecontroller.php.


Member Function Documentation

CommandsBaseController::action_commands_post ( page_data  ) 

Find according commands and redirect.

Definition at line 50 of file commands.basecontroller.php.

00050                                                          {
00051                 $page_data->in_history = false;
00052                 $err = new Status();
00053                 
00054                 if ($page_data->has_post_data() == true) {
00055                         $err = $this->redirect_to_handler($page_data);
00056                 }
00057                 else {
00058                         $err->append(tr('No command data was send', 'core'));
00059                 }
00060                 
00061                 History::go_to(0, $err);
00062                 exit;
00063         }
CommandsBaseController::get_routes (  ) 

Return array of IDispatchToken this controller takes responsability.

Reimplemented from ControllerBase.

Definition at line 41 of file commands.basecontroller.php.

00041                                      {
00042                 return array(
00043                         new ExactMatchRoute('https://post_command', $this, 'commands_post', new NoCacheCacheManager()),
00044                 );
00045         }

The documentation for this class was generated from the following file: