Class PHRUTS_MessageResources

Description

General purpose abstract class that describes an API for retrieving Locale-sensitive messages from underlying resource locations of an unspecified design.

Calls to getMessage with a null PHRUTS_Locale argument are presumed to be requesting a message string in the message resources default behaviour(implemented by the concrete subclass).

Calls to getMessage with an unknown key, or an unknown PHRUTS_Locale will return null if the returnNull property is set to true. Otherwise, a suitable error message will be returned instead.

  • author: John WILDENAUER <jwilde@users.sourceforge.net> (PHP4 port of Struts)
  • author: Olivier HENRY <oliv.henry@gmail.com> (PHP5 port of Struts)
  • version: $Id: PHRUTS_MessageResources.php,v 1.2 2008/05/24 13:32:44 ohenry Exp $
  • copyright: Copyright PHruts 2008
  • abstract:

Located in /util/PHRUTS_MessageResources.php (line 40)


	
			
Direct descendents
Class Description
PHRUTS_PropertyMessageResources Concrete subclass of PHRUTS_MessageResources that reads message keys and corresponding strings from named property resources.
Variable Summary
static Logger $log
string $config
array $formats
boolean $returnNull
Method Summary
PHRUTS_MessageResources __construct (string $config, [boolean $returnNull = false])
string formatMessage (string $message, [string $arg0 = null], [string $arg1 = null], [string $arg2 = null], [string $arg3 = null])
void getBaseMessage (PHRUTS_locale $locale, string $key)
string getConfig ()
string getMessage (PHRUTS_Locale $locale, string $key, [string $arg0 = null], [string $arg1 = null], [string $arg2 = null], [string $arg3 = null])
boolean getReturnNull ()
boolean isPresent (PHRUTS_Locale $locale, string $key)
string localeKey (PHRUTS_Locale $locale)
string messageKey (PHRUTS_Locale $locale, string $key)
string messageKeyByLocaleKey (string $localeKey, string $key)
void setReturnNull (boolean $returnNull)
void __wakeup ()
Variables
static Logger $log = null (line 46)

Logging instance.

  • access: protected
string $config = null (line 54)

The configuration parameter used to initialize this PHRUTS_MessageResources.

  • access: protected
PHRUTS_Locale $defaultLocale = null (line 61)

The default PHRUTS_Locale for our environment.

  • access: protected
array $formats = array() (line 69)

The set of previously created formated messages, keyed by the key computed in messageKey method.

  • access: protected
boolean $returnNull = false (line 77)

Indicate if a null is returned instead of an error message string when an unknown Locale or key is requested.

  • access: protected
Methods
Constructor __construct (line 94)

Construct a new PHRUTS_MessageResources according to the specified parameters.

  • access: public
PHRUTS_MessageResources __construct (string $config, [boolean $returnNull = false])
  • string $config: The configuration parameter for this PHRUTS_MessageResources
  • boolean $returnNull: The returnNull property we should initialize with

Redefined in descendants as:
formatMessage (line 264)

Format the message pattern by replacing the {0}-{3} parameters with the corresponding args array parameters.

  • return: Returns the formatted message string.
  • access: private
string formatMessage (string $message, [string $arg0 = null], [string $arg1 = null], [string $arg2 = null], [string $arg3 = null])
  • string $message: The message pattern to format
  • string $arg0: The replacement for placeholder {0} in the message
  • string $arg1: The replacement for placeholder {1} in the message
  • string $arg2: The replacement for placeholder {2} in the message
  • string $arg3: The replacement for placeholder {3} in the message
getBaseMessage (line 186)

Returns a text message for the specified key and the specified PHRUTS_Locale.

A null string result will be returned by this method if no relevant message resource is found for this key or PHRUTS_Locale, if the returnNull property is set. Otherwise, an appropriate error message will be returned.

This method must be implemented by a concrete subclass.

  • abstract:
  • access: protected
void getBaseMessage (PHRUTS_locale $locale, string $key)
  • PHRUTS_locale $locale: The requested message PHRUTS_Locale, or null for the system default PHRUTS_Locale
  • string $key: The message key to look up

Redefined in descendants as:
getConfig (line 111)

The configuration parameter used to initialize this PHRUTS_MessageResources.

  • return: Parameter used to initialize this PHRUTS_MessageResources
  • access: public
string getConfig ()
getMessage (line 150)

Returns a text message after parametric replacement of the specified parameter placeholders.

  • access: public
string getMessage (PHRUTS_Locale $locale, string $key, [string $arg0 = null], [string $arg1 = null], [string $arg2 = null], [string $arg3 = null])
  • PHRUTS_Locale $locale: The requested message PHRUTS_Locale, or null for the system default PHRUTS_Locale
  • string $key: The message key to look up
  • string $arg0: The replacement for placeholder {0} in the message
  • string $arg1: The replacement for placeholder {1} in the message
  • string $arg2: The replacement for placeholder {2} in the message
  • string $arg3: The replacement for placeholder {3} in the message
getReturnNull (line 122)

Indicates that a null is returned instead of an error message string if an unknown PHRUTS_Locale or key is requested.

  • return: True if null is returned if unknown key or locale is requested
  • access: public
boolean getReturnNull ()
isPresent (line 198)

Return true if there is a defined message for the specified key in the specified PHRUTS_Locale.

  • todo: Check if the parameter is a PHRUTS_Locale object.
  • access: public
boolean isPresent (PHRUTS_Locale $locale, string $key)
  • PHRUTS_Locale $locale: The requested message PHRUTS_Locale, or null for the system default PHRUTS_Locale
  • string $key: The message key to look up
localeKey (line 219)

Compute and return a key to be used in caching information by a PHRUTS_Locale.

NOTE: The locale key for the default PHRUTS_Locale in our environment is a zero length String.

  • todo: Check if the parameter is a PHRUTS_Locale object.
  • access: protected
string localeKey (PHRUTS_Locale $locale)
messageKey (line 236)

Compute and return a key to be used in caching information by PHRUTS_Locale and message key.

  • access: protected
string messageKey (PHRUTS_Locale $locale, string $key)
  • PHRUTS_Locale $locale: The locale key for which this cache key is calculated
  • string $key: The message key for which this cache key is calculated
messageKeyByLocaleKey (line 249)

Compute and return a key to be used in caching information by locale key and message key.

  • access: protected
string messageKeyByLocaleKey (string $localeKey, string $key)
  • string $localeKey: The locale key for which this cache key is calculated
  • string $key: The message key for which this cache key is calculated
setReturnNull (line 133)

Indicates that a null is returned instead of an error message string if an unknown locale or key is requested.

  • access: public
void setReturnNull (boolean $returnNull)
  • boolean $returnNull: True indicates that a null is returned if an unknown locale or key is requested.
__wakeup (line 79)
  • access: public
void __wakeup ()

Documentation generated on Sat, 31 May 2008 15:46:20 +0200 by phpDocumentor 1.4.1