Skip to content

Commit

Permalink
Merge pull request #9 from itk-dev/feature/configuration
Browse files Browse the repository at this point in the history
Service configuration
  • Loading branch information
stankut authored Apr 20, 2023
2 parents bbe14ae + e408c62 commit 9021990
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/Plugin/os2web/DataLookup/ServiceplatformenBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function buildConfigurationForm(array $form, FormStateInterface $form_sta
'#maxlength' => 500,
'#title' => 'Service WSDL location',
'#default_value' => $this->configuration['wsdl'],
'#description' => $this->t('ex. CVROnline-SF1530/wsdl/token/OnlineService.wsdl, relative path would be automatically converted to absolute path'),
'#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.'),
];

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

/**
Expand Down Expand Up @@ -281,7 +284,7 @@ protected function query($method, array $request) {
if (!$this->isReady()) {
return [
'status' => FALSE,
'text' => $this->getStatus(),
'error' => $this->getStatus(),
];
}

Expand Down

0 comments on commit 9021990

Please sign in to comment.