126 lines
4.1 KiB
PHP
126 lines
4.1 KiB
PHP
<?php
|
|
|
|
class FiberPlanFiber extends mfBaseModel
|
|
{
|
|
private $editor;
|
|
private $creator;
|
|
private $cable;
|
|
private $branch_cable;
|
|
private $splitter;
|
|
|
|
public function getProperty($name)
|
|
{
|
|
if ($this->$name == null) {
|
|
|
|
if (!$this->id) {
|
|
return null;
|
|
}
|
|
|
|
if ($name == "creator") {
|
|
$this->creator = mfValuecache::singleton()->get("Worker-id-" . $this->create_by);
|
|
if ($this->creator === null) {
|
|
$this->creator = new User($this->create_by);
|
|
if ($this->creator->id) {
|
|
mfValuecache::singleton()->set("Worker-id-" . $this->create_by, $this->creator);
|
|
}
|
|
}
|
|
return $this->creator;
|
|
}
|
|
|
|
if ($name == "editor") {
|
|
$this->editor = mfValuecache::singleton()->get("Worker-id-" . $this->edit_by);
|
|
if ($this->editor === null) {
|
|
$this->editor = new User($this->edit_by);
|
|
if ($this->editor->id) {
|
|
mfValuecache::singleton()->set("Worker-id-" . $this->edit_by, $this->editor);
|
|
}
|
|
}
|
|
return $this->editor;
|
|
}
|
|
if ($name == "cable" && $this->cable_id) {
|
|
$this->cable = mfValuecache::singleton()->get("FiberPlanCable-id-" . $this->cable_id);
|
|
if (!$this->cable) {
|
|
$this->cable = new FiberPlanCable($this->cable_id);
|
|
if ($this->cable->id) {
|
|
mfValuecache::singleton()->set("FiberPlanCable-id-" . $this->cable_id, $this->cable);
|
|
}
|
|
}
|
|
return $this->cable;
|
|
}
|
|
if ($name == "branch_cable" && $this->branch_cable_nr) {
|
|
$this->branch_cable = mfValuecache::singleton()->get("Cable-nr-" . $this->branch_cable_nr);
|
|
if (!$this->branch_cable) {
|
|
$cables = FiberPlanCableModel::search(['description' => $this->branch_cable_nr]);
|
|
if (count($cables) > 0) {
|
|
$this->branch_cable = $cables[0];
|
|
mfValuecache::singleton()->set("Cable-nr-" . $this->branch_cable_nr, $this->branch_cable);
|
|
}
|
|
}
|
|
return $this->branch_cable;
|
|
}
|
|
|
|
$classname = ucfirst($name);
|
|
$idfield = $name . "_id";
|
|
$this->$name = mfValuecache::singleton()->get("mfObjectmodel-$name-" . $this->$idfield);
|
|
if (!$this->$name) {
|
|
$this->$name = new $classname($this->$idfield);
|
|
}
|
|
|
|
if ($this->$name->id) {
|
|
mfValuecache::singleton()->set("mfObjectmodel-$name-" . $this->$name->id, $this->$name);
|
|
return $this->$name;
|
|
} else {
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
return $this->$name;
|
|
}
|
|
|
|
public function isBranchCable()
|
|
{
|
|
return ($this->branch_type == "Abzweigkabel");
|
|
}
|
|
|
|
public function isCustomerConnection()
|
|
{
|
|
return (!empty($this->home_id));
|
|
}
|
|
|
|
public function getFullPath()
|
|
{
|
|
$path = [];
|
|
$current = $this;
|
|
|
|
$path[] = [
|
|
'cable' => $current->cable,
|
|
'fiber' => $current,
|
|
'type' => 'main'
|
|
];
|
|
|
|
if ($current->isBranchCable() && $current->branch_cable) {
|
|
$branch_fiber = FiberPlanFiberModel::findByFiberNr(
|
|
$current->branch_cable->id,
|
|
$current->branch_fiber_nr,
|
|
$current->branch_bundle_nr,
|
|
$current->branch_fiber_in_bundle
|
|
);
|
|
|
|
if ($branch_fiber) {
|
|
$path[] = [
|
|
'cable' => $current->branch_cable,
|
|
'fiber' => $branch_fiber,
|
|
'type' => 'branch'
|
|
];
|
|
|
|
if ($branch_fiber->isBranchCable()) {
|
|
$sub_path = $branch_fiber->getFullPath();
|
|
$path = array_merge($path, array_slice($sub_path, 1));
|
|
}
|
|
}
|
|
}
|
|
|
|
return $path;
|
|
}
|
|
} |