Source for file Factory.class.php
Documentation is available at Factory.class.php
* Gumbo Library Framework
* This library is being released under the terms of the New BSD License. A
* copy of the license is packaged with the software (LICENSE.txt). If no
* copy is found, a copy of the license template can be found at:
* http://www.opensource.org/licenses/bsd-license.php
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* The class will return an object of the defined Class Name. It will automatically
* determine if the class uses the Singleton interface. It will pass arguments
* in the order they appear, but only through the 'new ClassName (..)' call.
* The Factory class returns any instance of an object, or null if any failures
* occur. This class can be easily extended by other Factories. The child factory
* would override the 'factory' method to perform specific operations on the input
* sent by the client. It would call the parent (Gumbo_Factory) factory method to
* get a new object. If the returned results are 'null', the child class would be
* able perform any extra processing before returning to the client.
* @copyright Copyright (c) 2007, iBayou, Michael Luster
* @license http://www.opensource.org/licenses/bsd-license.php New BSD License
* @author Michael Luster <mluster79@yahoo.com>
* @link http://sourceforge.net/projects/phpgumbo
* @desc Generic Factory Class
* @see Gumbo_Converter, Gumbo_Filter
gumbo_load ("Interface_Factory");
* Returns an instantiated object.
* Each additional argument will be sent to the Constructor of the Object
* in the order as it appears.
* @precondition class_exists()
* @param string $name name of the class
* @param mixed $args additional arguments
* @throws Gumbo_Exception
public function factory ($name=
null, $args=
null) {
// verify that the class exists
// check if implements Singleton
if ($interface ==
"Gumbo_Interface_Singleton") {
// return Singleton Object
if ($key ==
0) { continue; }
// return new object instance
$reflection =
new ReflectionClass ($name);
$e->setFunction (__METHOD__
);