[e3d4e0a] | 1 | <?php
|
---|
| 2 |
|
---|
| 3 | // For older (pre-2.7.2) verions of google/apiclient
|
---|
| 4 | if (
|
---|
| 5 | file_exists(__DIR__ . '/../apiclient/src/Google/Client.php')
|
---|
| 6 | && !class_exists('Google_Client', false)
|
---|
| 7 | ) {
|
---|
| 8 | require_once(__DIR__ . '/../apiclient/src/Google/Client.php');
|
---|
| 9 | if (
|
---|
| 10 | defined('Google_Client::LIBVER')
|
---|
| 11 | && version_compare(Google_Client::LIBVER, '2.7.2', '<=')
|
---|
| 12 | ) {
|
---|
| 13 | $servicesClassMap = [
|
---|
| 14 | 'Google\\Client' => 'Google_Client',
|
---|
| 15 | 'Google\\Service' => 'Google_Service',
|
---|
| 16 | 'Google\\Service\\Resource' => 'Google_Service_Resource',
|
---|
| 17 | 'Google\\Model' => 'Google_Model',
|
---|
| 18 | 'Google\\Collection' => 'Google_Collection',
|
---|
| 19 | ];
|
---|
| 20 | foreach ($servicesClassMap as $alias => $class) {
|
---|
| 21 | class_alias($class, $alias);
|
---|
| 22 | }
|
---|
| 23 | }
|
---|
| 24 | }
|
---|
| 25 | spl_autoload_register(function ($class) {
|
---|
| 26 | if (0 === strpos($class, 'Google_Service_')) {
|
---|
| 27 | // Autoload the new class, which will also create an alias for the
|
---|
| 28 | // old class by changing underscores to namespaces:
|
---|
| 29 | // Google_Service_Speech_Resource_Operations
|
---|
| 30 | // => Google\Service\Speech\Resource\Operations
|
---|
| 31 | $classExists = class_exists($newClass = str_replace('_', '\\', $class));
|
---|
| 32 | if ($classExists) {
|
---|
| 33 | return true;
|
---|
| 34 | }
|
---|
| 35 | }
|
---|
| 36 | }, true, true);
|
---|