Patching readonly
This commit is contained in:
@@ -72,6 +72,56 @@ class Termination extends mfBaseModel {
|
||||
return $code;
|
||||
}
|
||||
|
||||
public function getLineworkportPairs() {
|
||||
$ports = $this->getProperty("workflowitems")["ports"]->value->value_string;
|
||||
if(!$ports) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$return = [];
|
||||
$return["range"] = [];
|
||||
$return["pairs"] = [];
|
||||
|
||||
$ports = preg_replace('/[^0-9-]+/', "", $ports);
|
||||
if(strpos($ports, "-") !== false) {
|
||||
// port range
|
||||
$this->log->debug("is range");
|
||||
$port_parts = explode("-", $ports);
|
||||
if(is_array($port_parts) && count($port_parts) == 2) {
|
||||
$from = $port_parts[0];
|
||||
$to = $port_parts[1];
|
||||
|
||||
if($port_parts[0] > $port_parts[1]) {
|
||||
$from = $port_parts[1];
|
||||
$to = $port_parts[0];
|
||||
}
|
||||
|
||||
$range = [];
|
||||
$pairs = [];
|
||||
|
||||
$mod = $from % 2;
|
||||
|
||||
for($i = $from; $i <= $to; $i++) {
|
||||
$range[] = intval($i);
|
||||
if($i % 2 == $mod && $i + 1 <= $to) {
|
||||
$pairs[] = $i."-".($i+1);
|
||||
}
|
||||
}
|
||||
|
||||
$return["range"] = $range;
|
||||
$return["pairs"] = $pairs;
|
||||
}
|
||||
} else {
|
||||
// single port
|
||||
$this->log->debug("not a range");
|
||||
$return["range"] = $ports;
|
||||
}
|
||||
|
||||
//var_dump($return);exit;
|
||||
return $return;
|
||||
|
||||
}
|
||||
|
||||
public function resetProperties() {
|
||||
$this->building = null;
|
||||
$this->status = null;
|
||||
|
||||
Reference in New Issue
Block a user