public function save() { $pref = CircuitsPreference::findOne(CircuitsPreference::MEICAN_NSA); $pref->value = $this->meicanNsa; if (!$pref->save()) { return false; } $pref = CircuitsPreference::findOne(CircuitsPreference::CIRCUITS_DEFAULT_PROVIDER_NSA); $pref->value = $this->defaultProviderNsa; if (!$pref->save()) { return false; } $pref = CircuitsPreference::findOne(CircuitsPreference::CIRCUITS_DEFAULT_CS_URL); $pref->value = $this->defaultCSUrl; if (!$pref->save()) { return false; } $pref = CircuitsPreference::findOne(CircuitsPreference::CIRCUITS_UNIPORT_ENABLED); $pref->value = $this->uniportsEnabled; if (!$pref->save()) { return false; } $pref = CircuitsPreference::findOne(CircuitsPreference::CIRCUITS_PROTOCOL); $pref->value = $this->protocol; if (!$pref->save()) { return false; } return true; }
private function checkRequesterUrl() { $pref = CircuitsPreference::findOne(CircuitsPreference::CIRCUITS_MEICAN_REQUESTER_URL); if ($pref) { $url = Url::toRoute("/circuits/requester", "http"); if ($pref->value != $url) { $pref->value = $url; $pref->save(); } } }
public function actionGetPortByDevice($id, $cols = null) { $query = Port::find()->where(['device_id' => $id])->orderBy(['name' => 'SORT ASC'])->asArray(); if (!CircuitsPreference::findOne(CircuitsPreference::CIRCUITS_UNIPORT_ENABLED)->getBoolean()) { $query->andWhere(['directionality' => Port::DIR_BI]); } if (CircuitsPreference::findOne(CircuitsPreference::CIRCUITS_PROTOCOL)->value == Service::TYPE_NSI_CSP_2_0) { $query->andWhere(['type' => Port::TYPE_NSI]); } $cols ? $data = $query->select(json_decode($cols))->all() : ($data = $query->all()); $temp = Json::encode($data); Yii::trace($temp); return $temp; }