Class PHRUTS_ActionErrors


A class that encapsulates the error messages being reported by the validate() method of a PHRUTS_ActionForm.

Validation errors are either global to the entire PHRUTS_ActionForm bean they are associated with, or they are specific to a particular bean property (and, therefore, a particular input field on the corresponding form).

Each individual error is described by an PHRUTS_ActionError object, which contains a message key (to be looked up in an appropriate message resources database), and up to four placeholder arguments used for parametric substitution in the resulting message.

  • author: John WILDENAUER <> (PHP4 port of Struts)
  • author: Olivier HENRY <> (PHP5 port of Struts)
  • version: $Id: PHRUTS_ActionErrors.php,v 1.3 2008/05/28 15:52:26 ohenry Exp $
  • copyright: Copyright PHruts 2008

Located in /action/PHRUTS_ActionErrors.php (line 41)

Class Constant Summary
 GLOBAL_ERROR = 'phruts::action::GLOBAL_ERROR'
Variable Summary
array $errors
integer $iCount
Method Summary
void add (string $property, PHRUTS_ActionError $error)
void clear ()
array get ([string $property = ''])
boolean isEmpty ()
array properties ()
integer size ([string $property = ''])
array $errors = array() (line 54)

The accumulated set of PHRUTS_ActionError objects for each property, keyed by property name.

  • access: protected
integer $iCount = 0 (line 62)

The current number of the property/key being added. This is used to maintain the order errors are added.

  • access: protected
add (line 74)

Add an error message to the set of errors for the specified property.

An order of the property/key is maintained based on the initial addition of the property/key.

  • access: public
void add (string $property, PHRUTS_ActionError $error)
  • string $property: Property name (or PHRUTS_ActionErrors::GLOBAL_ERROR)
  • PHRUTS_ActionError $error: The error message to be added
clear (line 93)

Clear all errors recorded by this object.

  • access: public
void clear ()
get (line 118)

Return the set of errors related to a specific property or the set of all recorded errors (property = "") without distinction by which property the errors are associated with.

If there are no such errors, an empty array is returned.

  • access: public
array get ([string $property = ''])
  • string $property: The property name (or PHRUTS_ActionErrors::GLOBAL_ERROR)
isEmpty (line 103)

Return true if there are no errors recorded in this collection, or false otherwise.

  • access: public
boolean isEmpty ()
properties (line 161)

Return the set of property names for which at least one message has been recorded.

If there are no errors, an empty array is returned. If you have recorded global errors, the String value of PHRUTS_ActionErrors::GLOBAL_ERROR will be one of the returned property names.

  • access: public
array properties ()
size (line 176)

Return the number of errors associated with the specified property or for all properties (including global errors) if property is empty.


  • it is more efficient to call isEmpty if all
you care about is whether or not there are any errors at all.

  • access: public
integer size ([string $property = ''])
  • string $property: The property name (or PHRUTS_Actionerrors::GLOBAL_ERROR)
Class Constants
GLOBAL_ERROR = 'phruts::action::GLOBAL_ERROR' (line 46)

The "property name" marker to use for global errors, as opposed to those related to a specific property.

Documentation generated on Sat, 31 May 2008 15:45:50 +0200 by phpDocumentor 1.4.1