|
6 | 6 | * @author Christian Weiske <[email protected]>
|
7 | 7 | */
|
8 | 8 |
|
9 |
| -/** |
10 |
| - * Dead simple autoloader |
11 |
| - * |
12 |
| - * @param string $className Name of class to load |
13 |
| - * |
14 |
| - * @return void |
15 |
| - */ |
16 |
| -function __autoload($className) |
17 |
| -{ |
18 |
| - $className = ltrim($className, '\\'); |
19 |
| - $fileName = ''; |
20 |
| - if ($lastNsPos = strrpos($className, '\\')) { |
21 |
| - $namespace = substr($className, 0, $lastNsPos); |
22 |
| - $className = substr($className, $lastNsPos + 1); |
23 |
| - $fileName = str_replace('\\', DIRECTORY_SEPARATOR, $namespace) . DIRECTORY_SEPARATOR; |
24 |
| - } |
25 |
| - $fileName .= str_replace('_', DIRECTORY_SEPARATOR, $className) . '.php'; |
26 |
| - if (stream_resolve_include_path($fileName)) { |
27 |
| - require_once $fileName; |
28 |
| - } |
| 9 | +// support running this tool from git checkout |
| 10 | +$projectDirectory = dirname(__DIR__); |
| 11 | +if (is_dir($projectDirectory . DIRECTORY_SEPARATOR . 'vendor')) { |
| 12 | + set_include_path($projectDirectory . PATH_SEPARATOR . get_include_path()); |
29 | 13 | }
|
30 | 14 |
|
31 |
| -// support running this tool from git checkout |
32 |
| -if (is_dir(__DIR__ . '/../src/JsonSchema')) { |
33 |
| - set_include_path(__DIR__ . '/../src' . PATH_SEPARATOR . get_include_path()); |
| 15 | +// autoload composer classes |
| 16 | +$composerAutoload = stream_resolve_include_path('vendor/autoload.php'); |
| 17 | +if (!$composerAutoload) { |
| 18 | + echo("Cannot load json-schema library\n"); |
| 19 | + exit(1); |
34 | 20 | }
|
| 21 | +require($composerAutoload); |
35 | 22 |
|
36 | 23 | $arOptions = array();
|
37 | 24 | $arArgs = array();
|
|
0 commit comments