phpDocumentor ZNF
Actions
[ class tree: ZNF ] [ index: ZNF ] [ all elements ]

Class: ZNF_Actions_DispatchAction

Source Location: /Actions/DispatchAction.php

Class ZNF_Actions_DispatchAction

Class Overview

ZNF_Actions_DispatchAction is an abstract ZNF_Action_Action that dispatches to a public method that is named by the request parameter whose name is specified by the parameter property of the corresponding ZNF_Action_ActionMapping.

This action is useful for developers who prefer to combine many similar actions into a single ZNF_Actions_DispatchAction class, in order to simplify their application design.

There are several way the configure this action in your module configuration file.

  • Usage of the parameter attribute
<action path="customAction" type="Package_Action_CustomDispatchAction" parameter="method@location"/>

This action will use the value of the request parameter named method to pick the appropriate execute method, which must have the same signature (other than method name) of the standard ZNF_Actions_DispatchAction->execute() method. For example, you might have the following three methods in the same action class:

  • public function create($form, $mapping)
  • public function update($form, $mapping)
  • public function delete($form, $mapping)
And call one of them with a URL like this: http://<yourhost>/&lT;yourapp>/znf/action?method=update

The second part of the parameter attribute (@location) is optional and it is used to specify where to find the requested parameter, possible values are: 'GET', 'POST', 'REQUEST' and 'SESSION'. Considering the example above it should be replaced by 'GET', anyway if not specified it will be assumed the 'GET' value anyway.

  • Usage of the parameterValue attribute
<action path="customAction" type="Package_Action_CustomDispatchAction" parameterValue="update"/>

The parameterValue attribute is used to specify directly the name of the method that it will be called, considering the configuration above it will becalled the update method of the ZNF_Actions_CustomDispatchAction class.

<p><strong>NOTE</strong> - parameter and parameterValues attribute are exclusive and if any of them is specified or the result value is empty or execute, a method named unspecified is called. The default action is to throw an exception. You can override the unspecified method in your subclass.

Located in /Actions/DispatchAction.php [line 91]



		
				Author(s):
		
		
		API Tags:
Abstract:  
Access:  public

Information Tags:
Version:  SVN $Id: DispatchAction.php 43 2007-06-26 23:36:35Z aronnax $
Copyright:  2004-2007 The ZNF Development Team
Link:  http://www.zeronotice.org
Since:  Release 0.7.0
License:  LGPL

Methods

[ Top ]
Method Summary
ZNF_Actions_DispatchAction   __construct()   Constructs a new ZNF_Actions_DispatchAction object.
void   __destruct()   Destroys the ZNF_Actions_DispatchAction object.
ZNF_Action_ActionForward   execute()   Code to check and execute the action, subclasses must implement the method requested.
void   unspecified()   Default method to execute if the requested method is not found or the parameter attibute in the configuration file is not specified.

[ Top ]
Methods
Constructor __construct  [line 99]

  ZNF_Actions_DispatchAction __construct( )

Constructs a new ZNF_Actions_DispatchAction object.


API Tags:
Access:  public


[ Top ]
Destructor __destruct  [line 193]

  void __destruct( )

Destroys the ZNF_Actions_DispatchAction object.


API Tags:
Access:  public


[ Top ]
execute  [line 114]

Code to check and execute the action, subclasses must implement the method requested.

If the method required is not implemented by the subclass the unspecified method is called.

Parameters:
ZNF_Action_ActionForm   $form: 
ZNF_Action_ActionMapping   $mapping: 

API Tags:
Access:  public


[ Top ]
unspecified  [line 182]

  void unspecified( ZNF_Action_ActionForm $form, ZNF_Action_ActionMapping $mapping  )

Default method to execute if the requested method is not found or the parameter attibute in the configuration file is not specified.

Subclasses can override this method to customize the error.

Parameters:
ZNF_Action_ActionForm   $form: 
ZNF_Action_ActionMapping   $mapping: 

API Tags:
Access:  public


[ Top ]

Documentation generated on Wed, 14 Nov 2007 23:47:36 +0100 by phpDocumentor 1.4.0