| 1 |
<?php |
| 2 |
|
| 3 |
define("GOOGLE_INTERNAL_NAMESPACE", "Google\\Protobuf\\Internal\\"); |
| 4 |
define("GOOGLE_NAMESPACE", "Google\\Protobuf\\"); |
| 5 |
define("GOOGLE_GPBMETADATA_NAMESPACE", "GPBMetadata\\Google\\Protobuf\\"); |
| 6 |
define("BENCHMARK_NAMESPACE", "Benchmarks"); |
| 7 |
define("BENCHMARK_GPBMETADATA_NAMESPACE", "GPBMetadata\\Benchmarks"); |
| 8 |
|
| 9 |
function protobuf_autoloader_impl($class, $prefix, $include_path) { |
| 10 |
$length = strlen($prefix); |
| 11 |
if ((substr($class, 0, $length) === $prefix)) { |
| 12 |
$path = $include_path . '/' . implode('/', array_map('ucwords', explode('\\', $class))) . '.php'; |
| 13 |
include_once $path; |
| 14 |
} |
| 15 |
} |
| 16 |
|
| 17 |
function protobuf_autoloader($class) { |
| 18 |
protobuf_autoloader_impl($class, GOOGLE_INTERNAL_NAMESPACE, getenv('PROTOBUF_PHP_SRCDIR')); |
| 19 |
protobuf_autoloader_impl($class, GOOGLE_NAMESPACE, getenv('PROTOBUF_PHP_SRCDIR')); |
| 20 |
protobuf_autoloader_impl($class, GOOGLE_GPBMETADATA_NAMESPACE, getenv('PROTOBUF_PHP_SRCDIR')); |
| 21 |
protobuf_autoloader_impl($class, BENCHMARK_NAMESPACE, getenv('CURRENT_DIR')); |
| 22 |
protobuf_autoloader_impl($class, BENCHMARK_GPBMETADATA_NAMESPACE, getenv('CURRENT_DIR')); |
| 23 |
} |
| 24 |
|
| 25 |
spl_autoload_register('protobuf_autoloader'); |