From 9e3c25caea7eece2dee44ff818e9699d80735afe Mon Sep 17 00:00:00 2001 From: Vaidas Lungis Date: Tue, 31 Mar 2015 08:44:44 +0300 Subject: [PATCH] update SolusVM setConfig() --- src/bb-modules/Servicesolusvm/SolusVM.php | 34 ++++++++++++++--------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/bb-modules/Servicesolusvm/SolusVM.php b/src/bb-modules/Servicesolusvm/SolusVM.php index 206c7bc4c..7a2dde62f 100644 --- a/src/bb-modules/Servicesolusvm/SolusVM.php +++ b/src/bb-modules/Servicesolusvm/SolusVM.php @@ -22,6 +22,24 @@ class SolusVM implements \Box\InjectionAwareInterface{ return $this->di; } + public function getSecureUrl(array $config) + { + $cport = "5656"; + if ($config["port"]) { + $cport = $config["port"]; + } + return "https://" . $config['ipaddress'] . ":" . $cport . "/api/" . $config['usertype'] . "/command.php"; + } + + public function getUrl(array $config) + { + $cport = "5353"; + if ($config["port"]) { + $cport = $config["port"]; + } + return "http://" . $config['ipaddress'] . ":" . $cport . "/api/" . $config['usertype'] . "/command.php"; + } + public function setConfig(array $c) { $required = array( @@ -35,20 +53,10 @@ class SolusVM implements \Box\InjectionAwareInterface{ $c['secure'] = $this->di['array_get']($c, 'secure', false); $c['port'] = $this->di['array_get']($c, 'port', null); + $url = $this->getUrl($c); + if ($c['secure']) { - if ($c["port"]) { - $cport = $c["port"]; - } else { - $cport = "5656"; - } - $url = "https://" . $c['ipaddress'] . ":" . $cport . "/api/" . $c['usertype'] . "/command.php"; - } else { - if ($c["port"]) { - $cport = $c["port"]; - } else { - $cport = "5353"; - } - $url = "http://" . $c['ipaddress'] . ":" . $cport . "/api/" . $c['usertype'] . "/command.php"; + $url = $this->getSecureUrl($url); } $this->api_host = $url;