src/Zend/Loader/AutoloaderFactory.php
public static function factory($options = null)
    {
        if (null === $options) {
            if (!isset(self::$loaders[self::STANDARD_AUTOLOADER])) {
                $autoloader = self::getStandardAutoloader();
                $autoloader->register();
                self::$loaders[self::STANDARD_AUTOLOADER] = $autoloader;
            }

            // Return so we don't hit the next check's exception (we're done here anyway)
            return;
        }

        if (!is_array($options) && !($options instanceof Traversable)) {

            throw new Zend_Loader_Exception_InvalidArgumentException(
                'Options provided must be an array or Traversable'
            );
        }

        foreach ($options as $class => $options) {
            if (!isset(self::$loaders[$class])) {
                $autoloader = self::getStandardAutoloader();
                if (!class_exists($class) && !$autoloader->autoload($class)) {

                    throw new Zend_Loader_Exception_InvalidArgumentException(sprintf(
                        'Autoloader class "%s" not loaded', 
                        $class
                    ));
                }

                // unfortunately is_subclass_of is broken on some 5.3 versions
                // additionally instanceof is also broken for this use case
                if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
                        if (!is_subclass_of($class, 'Zend_Loader_SplAutoloader')) {

                        throw new Zend_Loader_Exception_InvalidArgumentException(sprintf(
                            'Autoloader class %s must implement Zend\\Loader\\SplAutoloader', 
                            $class
                        ));
                    }
                }

                if ($class === self::STANDARD_AUTOLOADER) {
                    $autoloader->setOptions($options);
                } else {
                    $autoloader = new $class($options);
                }
                $autoloader->register();
                self::$loaders[$class] = $autoloader;
            } else {
                self::$loaders[$class]->setOptions($options);
            }
        }
    }
public static function factory($options = null)
    {
        if (null === $options) {
            if (!isset(self::$loaders[self::STANDARD_AUTOLOADER])) {
                $autoloader = self::getStandardAutoloader();
                $autoloader->register();
                self::$loaders[self::STANDARD_AUTOLOADER] = $autoloader;
            }

            // Return so we don't hit the next check's exception (we're done here anyway)
            return;
        }

        if (!is_array($options) && !($options instanceof Traversable)) {

            throw new Zend_Loader_Exception_InvalidArgumentException(
                'Options provided must be an array or Traversable'
            );
        }

        foreach ($options as $class => $options) {
            if (!isset(self::$loaders[$class])) {
                $autoloader = self::getStandardAutoloader();
                if (!class_exists($class) && !$autoloader->autoload($class)) {

                    throw new Zend_Loader_Exception_InvalidArgumentException(sprintf(
                        'Autoloader class "%s" not loaded', 
                        $class
                    ));
                }

                // unfortunately is_subclass_of is broken on some 5.3 versions
                // additionally instanceof is also broken for this use case
                if (version_compare(PHP_VERSION, '5.3.7', '>=')) {
                        if (!is_subclass_of($class, 'Zend_Loader_SplAutoloader')) {

                        throw new Zend_Loader_Exception_InvalidArgumentException(sprintf(
                            'Autoloader class %s must implement Zend\\Loader\\SplAutoloader', 
                            $class
                        ));
                    }
                }

                if ($class === self::STANDARD_AUTOLOADER) {
                    $autoloader->setOptions($options);
                } else {
                    $autoloader = new $class($options);
                }
                $autoloader->register();
                self::$loaders[$class] = $autoloader;
            } else {
                self::$loaders[$class]->setOptions($options);
            }
        }
    }
public static function factory ( $ options = null ) { if ( null === $ options ) { if ( ! isset ( self :: $ loaders [ self :: STANDARD_AUTOLOADER ] ) ) { $ autoloader = self :: getStandardAutoloader ( ) ; $ autoloader -> register ( ) ; self :: $ loaders [ self :: STANDARD_AUTOLOADER ] = $ autoloader ; } // Return so we don't hit the next check's exception (we're done here anyway) return ; } if ( ! is_array ( $ options ) && ! ( $ options instanceof Traversable ) ) { throw new Zend_Loader_Exception_InvalidArgumentException ( 'Options provided must be an array or Traversable' ) ; } foreach ( $ options as $ class => $ options ) { if ( ! isset ( self :: $ loaders [ $ class ] ) ) { $ autoloader = self :: getStandardAutoloader ( ) ; if ( ! class_exists ( $ class ) && ! $ autoloader -> autoload ( $ class ) ) { throw new Zend_Loader_Exception_InvalidArgumentException ( sprintf ( 'Autoloader class "%s" not loaded' , $ class ) ) ; } // unfortunately is_subclass_of is broken on some 5.3 versions // additionally instanceof is also broken for this use case if ( version_compare ( PHP_VERSION , '5.3.7' , '>=' ) ) { if ( ! is_subclass_of ( $ class , 'Zend_Loader_SplAutoloader' ) ) { throw new Zend_Loader_Exception_InvalidArgumentException ( sprintf ( 'Autoloader class %s must implement Zend\\Loader\\SplAutoloader' , $ class ) ) ; } } if ( $ class === self :: STANDARD_AUTOLOADER ) { $ autoloader -> setOptions ( $ options ) ; } else { $ autoloader = new $ class ( $ options ) ; } $ autoloader -> register ( ) ; self :: $ loaders [ $ class ] = $ autoloader ; } else { self :: $ loaders [ $ class ] -> setOptions ( $ options ) ; } } }
Factory for autoloaders

Options should be an array or Traversable object of the following structure:
<code>
array(
'<autoloader class name>' => $autoloaderOptions,
)
</code>

The factory will then loop through and instantiate each autoloader with
the specified options, and register each with the spl_autoloader.

You may retrieve the concrete autoloader instances later using
{@link getRegisteredAutoloaders()}.

Note that the class names must be resolvable on the include_path or via
the Zend library, using PSR-0 rules (unless the class has already been
loaded).

@param  array|Traversable $options (optional) options to use. Defaults to Zend_Loader_StandardAutoloader
@return void
@throws Zend_Loader_Exception_InvalidArgumentException for invalid options
@throws Zend_Loader_Exception_InvalidArgumentException for unloadable autoloader classes
Factory for autoloaders