Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 99 lines (87 sloc) 3.571 kB
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
1 <?php
2 /**
3 *
4 * Copyright (C) 2010, 2011 Robin Harvey (harvey.robin@gmail.com)
5 *
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public License
8 * as published by the Free Software Foundation; either version 2.1 of
9 * the License, or (at your option) any later version.
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
10
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
11 * This library is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
14 * Lesser General Public License for more details.
15
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
16 * You should have received a copy of the GNU Lesser General Public
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
17 * License along with this library; if not, write to the Free Software
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
19 * 02110-1301 USA
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
20 */
21
22 /**
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
23 * This file shows you how to use the different builds. For nspf, you
24 * must include the library and generated files in the shown sequence,
25 * for cpf put the amqp base dir on the system path and use a
26 * "standard" class loader.
27 *
28 * For the purposes of running the demos, both modes can be run either
29 * from a given directory (set via. the DEMO_LOADER_DIR) or from the
30 * distribution build dir (this is the default)
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
31 */
32
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
33 if (defined('DEMO_LOAD_NSPF')) {
34 $DIR = defined('DEMO_LOADER_DIR')
35 ? constant('DEMO_LOADER_DIR')
36 : sprintf("%s%s%s%s%s%s",
37 dirname(__DIR__),
38 DIRECTORY_SEPARATOR,
39 'build',
40 DIRECTORY_SEPARATOR,
41 'nspf',
42 DIRECTORY_SEPARATOR);
43
44 include $DIR . 'amqphp.protocol.abstrakt.php';
45 include $DIR . 'amqphp.wire.php';
46 include $DIR . 'amqphp.php';
47 include $DIR . 'amqphp.persistent.php';
48 include $DIR . 'amqphp.protocol.v0_9_1.php';
49 include $DIR . 'amqphp.protocol.v0_9_1.basic.php';
50 include $DIR . 'amqphp.protocol.v0_9_1.channel.php';
51 include $DIR . 'amqphp.protocol.v0_9_1.confirm.php';
52 include $DIR . 'amqphp.protocol.v0_9_1.connection.php';
53 include $DIR . 'amqphp.protocol.v0_9_1.exchange.php';
54 include $DIR . 'amqphp.protocol.v0_9_1.queue.php';
55 include $DIR . 'amqphp.protocol.v0_9_1.tx.php';
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
56 } else {
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
57 $DIR = defined('DEMO_LOADER_DIR')
58 ? constant('DEMO_LOADER_DIR')
59 : sprintf("%s%s%s%s%s%s%s",
60 dirname(__DIR__),
61 DIRECTORY_SEPARATOR,
62 'build',
63 DIRECTORY_SEPARATOR,
64 'cpf',
65 DIRECTORY_SEPARATOR,
66 PATH_SEPARATOR);
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
67
24db59f @BraveSirRobin Major refactoring of demos to remove boilerplace code.
authored
68 set_include_path($DIR . get_include_path());
2bb8eea @BraveSirRobin An include file which acts as a switch, demos can load from either the
authored
69
70 class DefaultLoader
71 {
72 function load ($class) {
73 $target = implode(DIRECTORY_SEPARATOR, explode('\\', $class)) . '.php';
74 include $target;
75 if (! (class_exists($class, false) || interface_exists($class, false))) {
76 throw new Exception("Failed to load {$class} (2)", 6473);
77 }
78 }
79 }
80
81 // Ronseal
82 function RegisterDefaultLoader () {
83 AddLoader(array(new DefaultLoader(), 'load'));
84 }
85
86
87 /**
88 * Wrapper around spl_autoload_register, defaults to prepending loaders
89 * to the spl stack, this is the opposite of the default spl behaviour.
90 */
91 function AddLoader ($loaderClass, $append=false) {
92 if (false === spl_autoload_register($loaderClass, false, !$append)) {
93 throw new Exception("Failed to register loader", 8754);
94 }
95 }
96
97
98 RegisterDefaultLoader();
99 }
Something went wrong with that request. Please try again.