/** * Attempts to return a reference to a concrete Horde_Form_Renderer * instance based on $renderer. It will only create a new instance if no * Horde_Form_Renderer instance with the same parameters currently exists. * * This should be used if multiple types of form renderers (and, * thus, multiple Horde_Form_Renderer instances) are required. * * This method must be invoked as: $var = &Horde_Form_Renderer::singleton() * * @param mixed $renderer The type of concrete Horde_Form_Renderer * subclass to return. The code is dynamically * included. If $renderer is an array, then we will * look in $renderer[0]/lib/Form/Renderer/ for the * subclass implementation named $renderer[1].php. * @param array $params A hash containing any additional configuration a * form might need. * * @return Horde_Form_Renderer The concrete Horde_Form_Renderer reference, * or false on an error. */ function &singleton($renderer, $params = null) { static $instances = array(); $signature = serialize(array($renderer, $params)); if (!isset($instances[$signature])) { $instances[$signature] = Horde_Form_Renderer::factory($renderer, $params); } return $instances[$signature]; }