Skip to content

Commit aad3789

Browse files
author
Andrey Romashov
committed
add support multiple wsdl in config inputFile
1 parent 12cde49 commit aad3789

File tree

5 files changed

+29
-10
lines changed

5 files changed

+29
-10
lines changed

src/Filter/ServiceOperationFilter.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ public function filter(Service $service)
7878
// Remove duplicated using standard equality checks. Default string
7979
// comparison does not work here.
8080
$types = array_unique($types, SORT_REGULAR);
81-
$filteredService = new Service($this->config, $service->getIdentifier(), $types, $service->getDescription());
81+
$filteredService = new Service($this->config, $service->getIdentifier(), $types, $service->getDescription(), $service->getWsdl());
8282
// Pull created service with operations
8383
foreach ($operations as $operation) {
8484
$filteredService->addOperation($operation);

src/Generator.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,13 +84,13 @@ public function generate(ConfigInterface $config)
8484
if (is_array($wsdl)) {
8585
foreach ($wsdl as $ws) {
8686
$this->load($ws);
87+
$this->savePhp();
8788
}
8889
} else {
8990
$this->load($wsdl);
91+
$this->savePhp();
9092
}
9193

92-
$this->savePhp();
93-
9494
$this->log('Generation complete', 'info');
9595
}
9696

@@ -106,18 +106,20 @@ protected function load($wsdl)
106106
$this->types = [];
107107

108108
$this->loadTypes();
109-
$this->loadService();
109+
$this->loadService($wsdl);
110110
}
111111

112112
/**
113113
* Loads the service class.
114+
*
115+
* @param string $wsldUrl
114116
*/
115-
protected function loadService()
117+
protected function loadService($wsldUrl)
116118
{
117119
$service = $this->wsdl->getService();
118120
$this->log('Starting to load service '.$service->getName());
119121

120-
$this->service = new Service($this->config, $service->getName(), $this->types, $service->getDocumentation());
122+
$this->service = new Service($this->config, $service->getName(), $this->types, $service->getDocumentation(), $wsldUrl);
121123

122124
foreach ($this->wsdl->getOperations() as $function) {
123125
$this->log('Loading function '.$function->getName());

src/Service.php

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,24 @@ class Service implements ClassGenerator
5151
*/
5252
private $types;
5353

54+
/**
55+
* @var string a link to wsdl used when generate class
56+
*/
57+
private $wsdl;
58+
5459
/**
5560
* @param ConfigInterface $config Configuration
5661
* @param string $identifier The name of the service
5762
* @param array $types The types the service knows about
5863
* @param string $description The description of the service
64+
* @param string $wsld a link to wsdl
5965
*/
60-
public function __construct(ConfigInterface $config, $identifier, array $types, $description)
66+
public function __construct(ConfigInterface $config, $identifier, array $types, $description, $wsld)
6167
{
6268
$this->config = $config;
6369
$this->identifier = $identifier;
6470
$this->description = $description;
71+
$this->wsdl = $wsld;
6572
$this->operations = [];
6673
$this->types = [];
6774
foreach ($types as $type) {
@@ -135,6 +142,16 @@ public function getTypes()
135142
return $this->types;
136143
}
137144

145+
/**
146+
* Return url to wsdl.
147+
*
148+
* @return string
149+
*/
150+
public function getWsdl()
151+
{
152+
return $this->wsdl;
153+
}
154+
138155
/**
139156
* Generates the class if not already generated.
140157
*/
@@ -165,7 +182,7 @@ public function generateClass()
165182
}'.PHP_EOL;
166183
$source .= ' $options = array_merge('.var_export($this->config->get('soapClientOptions'), true).', $options);'.PHP_EOL;
167184
$source .= ' if (!$wsdl) {'.PHP_EOL;
168-
$source .= ' $wsdl = \''.$this->config->get('inputFile').'\';'.PHP_EOL;
185+
$source .= ' $wsdl = \''.$this->wsdl.'\';'.PHP_EOL;
169186
$source .= ' }'.PHP_EOL;
170187
$source .= ' parent::__construct($wsdl, $options);'.PHP_EOL;
171188

tests/src/Unit/Filter/ServiceOperationFilterTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ private function givenServiceWithOperations()
124124
$bookType,
125125
$requestSetVersion,
126126
];
127-
$service = new Service($this->config, 'Book_Shell', $types, 'Book shells');
127+
$service = new Service($this->config, 'Book_Shell', $types, 'Book shells', $this->config->get('inputFile'));
128128
$service->addOperation($getBookOperation);
129129
$service->addOperation($getAuthorsOperator);
130130
$service->addOperation($setVersionOperator);

tests/src/Unit/ServiceTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testSoapConfig()
4545
'soapClientOptions' => $this->soapclientOptions,
4646
]);
4747

48-
$service = new Service($config, 'TestService', [], 'Service description');
48+
$service = new Service($config, 'TestService', [], 'Service description', $this->wsdl);
4949
$this->generateClass($service, $this->namespace);
5050

5151
$this->assertClassExists('TestService', $this->namespace);

0 commit comments

Comments
 (0)