Class Support_Util


Shared utility functions for common tasks

Located in /support/lib/Support/Util.php (line 9)

Variable Summary
 static mixed $cached_models
Method Summary
 static object model (string $className)
 static array options_from_argument_list (array &$arguments)
 static void redirect (string $url, [bool $exit = true])
 static void validate_options (array $test, array $allowed)
static mixed $cached_models (line 11)
  • access: protected
static model (line 116)

Returns an instance of the named class. This is a convenience method

intended for performing class-level operations on models. Constructed instances are cached and returned to any future callers requesting the same class. If the class provides a method named set_readonly, it is invoked with a value of true.

In other words, this utility is a simple way to grab an immutable instance of a model class without littering up memory with lots of short-lived objects not associated with data records.

  • access: public
object model (string $className)
  • string $className: The name of the class to instantiate
static options_from_argument_list (line 92)

Return the options, if any, provided in a list of arguments and

remove the options from the arguments. This function assumes that the last argument in the list is an array of options if that argument is an associative array (see Support_ArrayHelper::is_associative()). If no options are found, an empty array is returned.

  • access: public
array options_from_argument_list (array &$arguments)
  • array &$arguments: The argument list to test/modify
static redirect (line 27)

Redirect to a given URL

  • access: public
void redirect (string $url, [bool $exit = true])
  • string $url: The URL or fragment to redirect to
  • bool $exit: If true (default), exists after returning the redirect
static validate_options (line 74)

Validate an options array against a set of permitted options. The

permitted options are specified as an array whose keys are the allowable option keys (e.g.

  1. array('a'=>1'b'=>1)
would allow option keys of
  1. 'a'
  1. 'b'
but not
  1. 'c'
. If any invalid option is specified in the test array, a Support_UnknownOptionError is thrown.

  • access: public
void validate_options (array $test, array $allowed)
  • array $test: The options array to test
  • array $allowed: The list of permitted options (see description)

Documentation generated on Wed, 25 Apr 2012 09:46:45 -0700 by phpDocumentor 1.4.3