Skip to content

Commit

Permalink
Preparing src for release 5.3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Vincent Tsao committed Jun 13, 2014
1 parent 592a945 commit f59e65b
Show file tree
Hide file tree
Showing 451 changed files with 226,503 additions and 6,195 deletions.
13 changes: 13 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
### 5.3.0

AdWords:
- Fixed [pull request #40](https://github.com/googleads/googleads-php-lib/pull/40).
- Fixed [pull request #39](https://github.com/googleads/googleads-php-lib/pull/39).

DFP:
- Deprecated ServiceUtils.php.
- Added support and examples for v201405.

Common:
- OAuth2 credentials are now passed via HTTP headers.

### 5.2.3

AdWords:
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ $user->LogDefaults();

// Instantiate the desired service class by calling the get***Service method on
// the AdWordsUser instance.
$campaignService = $user->GetService('CampaignService', 'v201309')
$campaignService = $user->GetService('CampaignService', 'v201309');

// Create data objects and invoke methods on the service class instance. The
// data objects and methods map directly to the data objects and requests for
Expand Down
33 changes: 15 additions & 18 deletions build_lib/WSDLInterpreter/WSDLInterpreter.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,11 +174,11 @@ class WSDLInterpreter
private $package = null;

/**
* Whether or not to enable psuedo namespaces in the generated class names.
* Whether or not to enable namespaces in the generated class names.
* @var string
* @access private
*/
private $enablePseudoNamespaces = null;
private $enableNamespaces = null;

/**
* The class path of the SOAP client to require in the PHP file.
Expand Down Expand Up @@ -241,14 +241,14 @@ class WSDLInterpreter
* @param string $soapClientClassPath the class path to require for the
* SOAP client
* @param string $proxy the proxy URL to use when downloading WSDLs
* @param boolean $enablePseudoNamespaces to enable the namespaces
* @param boolean $enableNamespaces to enable the namespaces
* @param array $skipClassNameCheckTypes ignore class name checking list
* @throws WSDLInterpreterException container for all WSDL interpretation
* problems
*/
public function __construct($wsdlUri, $soapClientClassName, $classmap,
$conflictClassmap, $serviceName, $version, $package, $soapClientClassPath,
$proxy, $enablePseudoNamespaces, $skipClassNameCheckTypes)
$proxy, $enableNamespaces, $skipClassNameCheckTypes)
{
// Configure the interpreter
$this->wsdlUri = $wsdlUri;
Expand All @@ -258,7 +258,7 @@ public function __construct($wsdlUri, $soapClientClassName, $classmap,
$this->version = $version;
$this->package = $package;
$this->classmap = $classmap ?: $this->classmap;
$this->enablePseudoNamespaces = $enablePseudoNamespaces ?: false;
$this->enableNamespaces = $enableNamespaces ?: false;

$conflictClassmap = $conflictClassmap ?: array();
$this->classmap = array_merge($this->classmap, $conflictClassmap);
Expand Down Expand Up @@ -292,7 +292,7 @@ public function __construct($wsdlUri, $soapClientClassName, $classmap,
// Prepare wsdl utility with the loaded settings
$this->utils->setRenameClassMap($this->classmap);
$this->utils->setSkipClassNameCheck($this->skipClassNameCheckTypes);
if ($this->enablePseudoNamespaces) {
if ($this->enableNamespaces) {
$this->utils->setPhpNamespace($this->package);
}
$this->utils->setWsdlNamespaceMap($this->namespaceMap);
Expand Down Expand Up @@ -525,7 +525,7 @@ private function generateClassPHP(WsdlElement_Class $class) {
$constructor = $this->generateConstructorPHP($class);

return <<<EOF
if (!class_exists("{$class->getName()}", false)) {
if (!class_exists("{$class->getQuotedFqn()}", false)) {
/**
{$paddedDocs}
* @package {$this->package}
Expand Down Expand Up @@ -681,7 +681,7 @@ private function generateServicePHP(WsdlElement_Service $service) {
* @package {$this->package}
* @subpackage {$this->version}
*/
class {$service->getName()} extends {$this->soapClientClassName} {
class {$service->getName()} extends {$this->utils->namespaceName($this->soapClientClassName)} {
const SERVICE_NAME = "{$service->getRawName()}";
const WSDL_NAMESPACE = "{$this->serviceNamespace}";
Expand Down Expand Up @@ -740,7 +740,7 @@ private function generateServiceClassmapPHP(WsdlElement_Service $service) {
EOF;
foreach ($this->wsdlClasses as $wsdlClass) {
$return .= sprintf(" \"%s\" => \"%s\",\n", $wsdlClass->getRawName(),
$wsdlClass->getName());
addslashes($wsdlClass->getFqn()));
}
$return .= " );\n\n";

Expand Down Expand Up @@ -793,23 +793,20 @@ public function {$rawName}({$functionArgString}) {
* @return array array of source code files that were written out
* @throws WSDLInterpreterException problem in writing out service sources
*/
public function savePHP($outputDirectory)
{
public function savePHP($outputDirectory) {
if (!count($this->servicePHPSources)) {
throw new WSDLInterpreterException("No services loaded");
}
$require = sprintf(
"/** Required classes. **/\nrequire_once \"%s\";\n\n",
$this->soapClientClassPath
);
$namespace = $this->enableNamespaces ? sprintf("namespace %s;\n\n",
$this->utils->getNamespace()) : '';
$require = sprintf("require_once \"%s\";\n\n", $this->soapClientClassPath);
$classSource = join("\n\n", $this->classPHPSources);
$outputFiles = array();
foreach ($this->servicePHPSources as $serviceName => $serviceCode) {
$filename = sprintf('%s/%s.php', $outputDirectory, $serviceName);
$success = file_put_contents($filename, sprintf(
"<?php\n%s\n%s%s\n\n%s",
$this->getFileHeader(), $require, $classSource, $serviceCode
));
"<?php\n%s%s%s%s\n\n%s\n\n", $this->getFileHeader(), $namespace,
$require, $classSource, $serviceCode));
if ($success) {
$outputFiles[] = $filename;
}
Expand Down
47 changes: 47 additions & 0 deletions build_lib/WSDLInterpreter/WsdlElement/NamedClass.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ abstract class WsdlElement_NamedClass extends WsdlElement_Named {
*/
protected $name;

/**
* Store the fully qualified name with namespace
*/
protected $fqn;

/**
* Store the fully qualified name with namespace, wrapped w/ addslashes.
* e.g., Google\Ads\MyClass => Google\\Ads\\MyClass
*/
protected $quotedFqn;


/**
* Store the PHP namespace, aka package
*/
protected $package;

/**
* An overridden constructor.
*
Expand All @@ -69,6 +86,33 @@ public function getName() {
return $this->name;
}

/**
* Returns the fully qualified class name with namespace.
*
* @return string the fully qualified name of the element
*/
public function getFqn() {
return $this->fqn;
}

/**
* Returns the fully qualified class name with namespace.
*
* @return string the fully qualified name of the element
*/
public function getQuotedFqn() {
return $this->quotedFqn;
}

/**
* Returns the PHP namespace.
*
* @return string the PHP namespace
*/
public function getPackage() {
return $this->name;
}

/**
* Get the array of doc lines.
*
Expand All @@ -88,6 +132,9 @@ public function getDocs() {
protected function initName() {
$name = $this->getRawName();
$this->name = $this->utils->filterClassName($name);
$this->fqn = $this->utils->namespaceName($this->name);
$this->package = $this->utils->getNamespace();
$this->quotedFqn = addslashes($this->fqn);

return $this;
}
Expand Down
10 changes: 8 additions & 2 deletions build_lib/WSDLInterpreter/WsdlElement/Utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public function filterClassName($name) {
$filteredName = $this->renameMap[$name];
}
$filteredName = ucfirst($this->getSafePhpName($filteredName));
$filteredName = $this->namespaceName($filteredName);

if (!in_array($filteredName, $this->skipClassList)
&& class_exists($filteredName, false)) {
Expand All @@ -148,11 +147,18 @@ public function filterClassName($name) {
*/
public function namespaceName($name) {
if ($this->namespace) {
return sprintf('%s_%s', $this->namespace, $name);
return sprintf('%s\\%s', $this->namespace, $name);
}
return $name;
}

/**
* Get the current namespace) {
*/
public function getNamespace() {
return $this->namespace;
}

public function getWsdlNamespace($name) {
return isset($this->namespaceMap[$name]) ? $this->namespaceMap[$name] :
null;
Expand Down
22 changes: 11 additions & 11 deletions build_lib/Wsdl2PhpTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,15 @@ class Wsdl2PhpTask extends Task {

/**
* A classmap of 'Wsdl Type => PHP Class' for the WSDL, to be used
* to avoid class name conflicts when pseudo namespaces are not enabled.
* to avoid class name conflicts when namespaces are not enabled.
* @var array the classmap for the WSDL type to PHP class
* @access private
*/
private $conflictClassmap = NULL;

/**
* The WSDL types that shouldn't have their class names checked for
* uniqueness. This option will be ignored when pseudo namespaces are enabled.
* uniqueness. This option will be ignored when namespaces are enabled.
* @var array the WSDL types that shouldn't have their class names checked for
* uniqueness.
* @access private
Expand Down Expand Up @@ -114,12 +114,12 @@ class Wsdl2PhpTask extends Task {
private $proxy = NULL;

/**
* Whether or not to enable pseudo namespaces in the generated class names.
* @var boolean whether or not to enable pseudo namespaces in the generated
* Whether or not to enable namespaces in the generated class names.
* @var boolean whether or not to enable namespaces in the generated
* class names
* @access private
*/
private $enablePseudoNamespaces = FALSE;
private $enableNamespaces = FALSE;

/**
* The setter for the attribute <var>$url</var>.
Expand Down Expand Up @@ -173,7 +173,7 @@ public function setClassmap($classmap) {
* The setter for the attribute <var>$conflictClassmap</var>.
* @param string $conflictClassmap JSON representation of a classmap, as a
* mapping from WSDL type to PHP class name, to be used to avoid name
* conflicts when pseudo namespaces aren't enabled
* conflicts when namespaces aren't enabled
*/
public function setConflictClassmap($conflictClassmap) {
$this->conflictClassmap = json_decode($conflictClassmap, true);
Expand Down Expand Up @@ -221,12 +221,12 @@ public function SetProxy($proxy) {
}

/**
* The setter for the attribute <var>$enablePseudoNamespaces</var>.
* @param boolean $enablePseudoNamespaces whether or not to enable pseudo
* The setter for the attribute <var>$enableNamespaces</var>.
* @param boolean $enableNamespaces whether or not to enable
* namespaces in the generated class names.
*/
public function SetEnablePseudoNamespaces($enablePseudoNamespaces) {
$this->enablePseudoNamespaces = $enablePseudoNamespaces;
public function SetEnableNamespaces($enableNamespaces) {
$this->enableNamespaces = $enableNamespaces;
}

/**
Expand All @@ -253,7 +253,7 @@ public function main() {
new WSDLInterpreter($this->url, $this->soapClientClassName,
$this->classmap, $this->conflictClassmap, $this->serviceName,
$this->version, $this->package, $this->soapClientClassPath,
$this->proxy, $this->enablePseudoNamespaces,
$this->proxy, $this->enableNamespaces,
$this->skipClassNameCheckTypes);
$wsdlInterpreter->savePHP($this->outputDir);

Expand Down
4 changes: 2 additions & 2 deletions build_lib/build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
<if>
<and>
<isset property="api.soapClientClassNamespace"/>
<not><isfalse value="${wsdl2php.enablePseudoNamespaces}" /></not>
<not><isfalse value="${wsdl2php.enableNamespaces}"/></not>
</and>
<then>
<property name="soapClientClassName"
Expand All @@ -79,7 +79,7 @@
soapClientClassName="${soapClientClassName}"
soapClientClassPath="Google/Api/Ads/${product}/Lib/${product}SoapClient.php"
proxy="${wsdl2php.proxy}"
enablePseudoNamespaces="${wsdl2php.enablePseudoNamespaces}"/>
enableNamespaces="${wsdl2php.enableNamespaces}"/>
</target>

</project>
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/Auth/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
error_reporting(E_STRICT | E_ALL);

$depth = '/../../../';
define('SRC_PATH', dirname(__FILE__) . $depth . 'lib/');
define('SRC_PATH', dirname(__FILE__) . $depth . 'src/');
define('LIB_PATH', 'Google/Api/Ads/AdWords/Lib');

// Configure include path.
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/v201309/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
error_reporting(E_STRICT | E_ALL);

$depth = '/../../../';
define('SRC_PATH', dirname(__FILE__) . $depth . 'lib/');
define('SRC_PATH', dirname(__FILE__) . $depth . 'src/');
define('LIB_PATH', 'Google/Api/Ads/AdWords/Lib');
define('UTIL_PATH', 'Google/Api/Ads/Common/Util');
define('ADWORDS_UTIL_PATH', 'Google/Api/Ads/AdWords/Util');
Expand Down
2 changes: 1 addition & 1 deletion examples/AdWords/v201402/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
error_reporting(E_STRICT | E_ALL);

$depth = '/../../../';
define('SRC_PATH', dirname(__FILE__) . $depth . 'lib/');
define('SRC_PATH', dirname(__FILE__) . $depth . 'src/');
define('LIB_PATH', 'Google/Api/Ads/AdWords/Lib');
define('UTIL_PATH', 'Google/Api/Ads/Common/Util');
define('ADWORDS_UTIL_PATH', 'Google/Api/Ads/AdWords/Util');
Expand Down
2 changes: 1 addition & 1 deletion examples/Adx/v201306/init.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
error_reporting(E_STRICT | E_ALL);

$depth = '/../../../';
define('SRC_PATH', dirname(__FILE__) . $depth . 'lib/');
define('SRC_PATH', dirname(__FILE__) . $depth . 'src/');
define('LIB_PATH', 'Google/Api/Ads/AdWords/Lib');
define('UTIL_PATH', 'Google/Api/Ads/Common/Util');
define('ADWORDS_UTIL_PATH', 'Google/Api/Ads/AdWords/Util');
Expand Down
Loading

0 comments on commit f59e65b

Please sign in to comment.