-
Notifications
You must be signed in to change notification settings - Fork 316
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: switch to namespaces and other modernizations (#363)
- Loading branch information
Showing
24,788 changed files
with
831,911 additions
and
890,090 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
// For older (pre-2.7.2) verions of google/apiclient | ||
if ( | ||
file_exists(__DIR__ . '/../apiclient/src/Google/Client.php') | ||
&& !class_exists('Google_Client', false) | ||
) { | ||
require_once(__DIR__ . '/../apiclient/src/Google/Client.php'); | ||
if ( | ||
defined('Google_Client::LIBVER') | ||
&& version_compare(Google_Client::LIBVER, '2.7.2', '<=') | ||
) { | ||
$servicesClassMap = [ | ||
'Google\\Client' => 'Google_Client', | ||
'Google\\Service' => 'Google_Service', | ||
'Google\\Service\\Resource' => 'Google_Service_Resource', | ||
'Google\\Model' => 'Google_Model', | ||
'Google\\Collection' => 'Google_Collection', | ||
]; | ||
foreach ($servicesClassMap as $alias => $class) { | ||
class_alias($class, $alias); | ||
} | ||
} | ||
} | ||
spl_autoload_register(function ($class) { | ||
if (0 === strpos($class, 'Google_Service_')) { | ||
// Autoload the new class, which will also create an alias for the | ||
// old class by changing underscores to namespaces: | ||
// Google_Service_Speech_Resource_Operations | ||
// => Google\Service\Speech\Resource\Operations | ||
$classExists = class_exists($newClass = str_replace('_', '\\', $class)); | ||
if ($classExists) { | ||
return true; | ||
} | ||
} | ||
}, true, true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 9 additions & 2 deletions
11
...ges/php/default/templates/___api_className___/Resource/___resources_className___.php.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,22 @@ | ||
<?php | ||
{% language php %}{% copyright_block %} | ||
|
||
namespace {{ api.ownerName }}\Service\{{ api.className }}\Resource; | ||
{% if resource.methodClasses %} | ||
{% for methodClass in resource.methodClasses %}use {{ api.ownerName }}\Service\{{ api.className }}\{{ methodClass }}{% if methodClass|lower == resource.className|lower or methodClass in api.resourceNames %} as {{ methodClass }}Model{% endif %}; | ||
{% endfor %}{% endif %} | ||
/** | ||
* The "{{ resource.wireName }}" collection of methods. | ||
* Typical usage is: | ||
* <code> | ||
* ${{ api.name }}Service = new {{ api.ownerName }}_Service_{{ api.className }}(...); | ||
* ${{ api.name }}Service = new {{ api.ownerName }}\Service\{{ api.className }}(...); | ||
* ${{ resource.codeName }} = ${{ api.name }}Service->{{ resource.codeName }}; | ||
* </code> | ||
*/ | ||
class {{ api.ownerName }}_Service_{{ api.className }}_Resource_{{ resource.className }} extends Google_Service_Resource | ||
class {{ resource.className }} extends \Google\Service\Resource | ||
{{% indent %}{% for method in resource.methods %} | ||
{% call_template _method method=method %}{% endfor %} | ||
{% endindent %}} | ||
|
||
// Adding a class alias for backwards compatibility with the previous class name. | ||
class_alias({{ resource.className }}::class, '{{ api.ownerName }}_Service_{{ api.className }}_Resource_{{ resource.className }}'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
20 changes: 10 additions & 10 deletions
20
generator/src/googleapis/codegen/languages/php/default/templates/_methods_decl.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,16 @@ | ||
array( | ||
'methods' => array( | ||
{% for method in methods %}{% literal method.wireName %} => array( | ||
[ | ||
'methods' => [ | ||
{% for method in methods %}{% literal method.wireName %} => [ | ||
'path' => {% literal method.path %}, | ||
'httpMethod' => {% literal method.httpMethod %}, | ||
'parameters' => array({% for p in method.parameters %} | ||
{% literal p.wireName %} => array( | ||
'parameters' => [{% for p in method.parameters %} | ||
{% literal p.wireName %} => [ | ||
'location' => {% literal p.location %}, | ||
'type' => {% literal p.type %}, | ||
{% if p.repeated %}'repeated' => true,{% endif %} | ||
{% if p.required %}'required' => true,{% endif %} | ||
), | ||
{% endfor %}), | ||
),{% endfor %} | ||
) | ||
) | ||
], | ||
{% endfor %}], | ||
],{% endfor %} | ||
] | ||
] |
2 changes: 1 addition & 1 deletion
2
generator/src/googleapis/codegen/languages/php/default/templates/_resource_decl.tmpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.