Skip to content

Commit 9021990

Browse files
authored
Merge pull request #9 from itk-dev/feature/configuration
Service configuration
2 parents bbe14ae + e408c62 commit 9021990

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/Plugin/os2web/DataLookup/ServiceplatformenBase.php

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
8484
'#maxlength' => 500,
8585
'#title' => 'Service WSDL location',
8686
'#default_value' => $this->configuration['wsdl'],
87-
'#description' => $this->t('ex. CVROnline-SF1530/wsdl/token/OnlineService.wsdl, relative path would be automatically converted to absolute path'),
87+
'#description' => $this->t('ex. CVROnline-SF1530/wsdl/token/OnlineService.wsdl. A relative path will be resolved relatively to the location of the OS2Web datalookup module.'),
8888
];
8989

9090
$form['location'] = [
@@ -236,13 +236,16 @@ private function init() {
236236
* WSDL URL.
237237
*/
238238
protected function getWsdlUrl() {
239-
$wsdl = $this->configuration['wsdl'];
240-
// If it is relative URL make is absolute.
241-
if (substr($wsdl, 0, 4) !== "http") {
242-
global $base_url, $base_path;
243-
$wsdl = $base_url . $base_path . drupal_get_path('module', 'os2web_datalookup') . '/' . $wsdl;
239+
$url = $this->configuration['wsdl'];
240+
// Anything that's not an absolute path or url will be resolved relative to
241+
// the location of the os2web_datalookup module.
242+
if (!preg_match('@^([a-z]+:/)?/@', $url)) {
243+
/** @var \Drupal\Core\Extension\ExtensionPathResolver $extensionPathResolver */
244+
$extensionPathResolver = \Drupal::service('extension.path.resolver');
245+
$path = realpath($extensionPathResolver->getPath('module', 'os2web_datalookup'));
246+
$url = 'file://' . $path . '/' . $url;
244247
}
245-
return $wsdl;
248+
return $url;
246249
}
247250

248251
/**
@@ -281,7 +284,7 @@ protected function query($method, array $request) {
281284
if (!$this->isReady()) {
282285
return [
283286
'status' => FALSE,
284-
'text' => $this->getStatus(),
287+
'error' => $this->getStatus(),
285288
];
286289
}
287290

0 commit comments

Comments
 (0)