Patching readonly

This commit is contained in:
Frank Schubert
2021-09-21 23:12:53 +02:00
parent 1d162fedb7
commit 3cc3f3f50c
8 changed files with 428 additions and 4 deletions

View File

@@ -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;