示例#1
0
#     require_once(realpath(dirname(__FILE__)) . '/../path/to/DevKit/Autoload.php' );
#   }
#   DevKit_Autoload::setprefix('YourBaseClass', realpath( $pathtoyourbaseclass ) );
#
#   # YourBaseClass, YourBaseClass_* classes now all dynamically loaded
#
#   require_once(realpath(dirname(__FILE__)) . '/../path/to/Dispatcher.php' );
#
#   # Dispatcher, Dispatcher_* , Dispatch, Dispatch_* classes now all dynamically loaded.
#
#=cut
if (!defined('DEVKIT_AUTOLOAD')) {
    require_once realpath(dirname(__FILE__)) . '/../extlib/DevKit/lib/DevKit/Autoload.php';
}
DevKit_Autoload::setprefix('Dispatcher', realpath(dirname(__FILE__)) . '/Dispatcher');
DevKit_Autoload::setprefix('Dispatch', realpath(dirname(__FILE__)) . '/Dispatch');
class Dispatcher
{
    private $rules;
    #=head2 METHODS
    #
    #=head3 new Dispatcher
    #
    #   $dispatcher = new Dispatcher(
    #      Dispatch::empty()->execute( $action ),
    #      ... more disptachers ...
    #      Dispatch::default()->execute( $action ),
    #   );
    #
    # This generates a new Dispatcher Object with a top-to-bottom list of rules/instructions to execute.
    # The dispatch tree is executed Once and Once only so this can be taken like a syntactic tree of complex
示例#2
0
         * capacity to hard-code where it is stored.
         */
        public static function setpath($class, $path)
        {
            self::$_hardpath[$class] = $path;
        }
        /**
         *
         *  DevKit_Autoload::setprefix( 'Foo_Bar' , dirname(__FILE__) . '/lib/Foo/Bar' );
         *  DevKit_Autoload::autoload( 'Foo_Bar' ) # dispatches as /lib/Foo/Bar.php
         *  DevKit_Autoload::autoload( 'Foo_Bar_Baz' ) # dispatches as /lib/Foo/Bar/Baz.php
         *
         * This is a way of permitting autoloading of multiple libraries without needing them
         * to all coexist in the one tree.
         *
         * The idea being, you have all your custom code in one tree, but all the consumed
         * in another, but still being able to smartly load from both.
         *
         * All prefixes that match are tested in order of *Most* specific to *least* specific.
         * We're not sure if this is wise yet or not for the case where 2 identical classes exist,
         * but if you need to selectively override the behaviour, there's always the hardpath.
         *
         */
        public static function setprefix($prefix, $path)
        {
            self::$_prefix[$prefix] = $path;
            uksort(self::$_prefix, array('self', 'prioritize_path'));
        }
    }
    DevKit_Autoload::setup();
}