From 3aa9aa9c8ec4560abd7525738bb997bf3bd12bc1 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 17 Apr 2023 10:54:54 +0200 Subject: [PATCH 1/3] Fixed typo --- src/Plugin/os2web/DataLookup/ServiceplatformenBase.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php index 26d5469..4e24dac 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php @@ -281,7 +281,7 @@ protected function query($method, array $request) { if (!$this->isReady()) { return [ 'status' => FALSE, - 'text' => $this->getStatus(), + 'error' => $this->getStatus(), ]; } From 8aac380e23372aadc8f187590db07651c7d2888f Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Mon, 17 Apr 2023 12:53:33 +0200 Subject: [PATCH 2/3] Improved handling of WSDL path --- .../DataLookup/ServiceplatformenBase.php | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php index 4e24dac..4ca2ea2 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php @@ -2,6 +2,7 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; +use Drupal\Core\Extension\ExtensionPathResolver; use Drupal\Core\Form\FormStateInterface; /** @@ -84,7 +85,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'] = [ @@ -236,13 +237,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 ExtensionPathResolver $extensionPathResolver */ + $extensionPathResolver = \Drupal::service('extension.path.resolver'); + $path = realpath($extensionPathResolver->getPath('module', 'os2web_datalookup')); + $url = 'file://'.$path.'/'.$url; } - return $wsdl; + return $url; } /** From e408c62148c1305a0cb70a87e886cda822c9c882 Mon Sep 17 00:00:00 2001 From: Mikkel Ricky Date: Thu, 20 Apr 2023 09:36:20 +0200 Subject: [PATCH 3/3] Applied coding standards --- src/Plugin/os2web/DataLookup/ServiceplatformenBase.php | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php index 4ca2ea2..51c3291 100644 --- a/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php +++ b/src/Plugin/os2web/DataLookup/ServiceplatformenBase.php @@ -2,7 +2,6 @@ namespace Drupal\os2web_datalookup\Plugin\os2web\DataLookup; -use Drupal\Core\Extension\ExtensionPathResolver; use Drupal\Core\Form\FormStateInterface; /** @@ -241,10 +240,10 @@ protected function getWsdlUrl() { // 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 ExtensionPathResolver $extensionPathResolver */ + /** @var \Drupal\Core\Extension\ExtensionPathResolver $extensionPathResolver */ $extensionPathResolver = \Drupal::service('extension.path.resolver'); $path = realpath($extensionPathResolver->getPath('module', 'os2web_datalookup')); - $url = 'file://'.$path.'/'.$url; + $url = 'file://' . $path . '/' . $url; } return $url; }