'edit'], ]; } public function beforeSave($insert) { if(parent::beforeSave($insert)){ if($this->isNewRecord){ } $this->_htmlTagFilter(); return true; } else { return false; } } public function _htmlTagFilter() { $this->content = Model::htmlTagFilter($this->content); } public function save() { if(!$this->validate()){ return $this->getModelError(); } $this->content = base64_encode($this->content); $r = Option::setOption($this->key, $this->content, $this->cx_mch_id); if (!$r){ return [ 'code' => 1, 'msg' => '保存失败' ]; } if(!empty($this->video_open)){ // 视频开关 $redis_name = "cxaibc:api:actionHandleVideo_v1"; if($this->video_open == 'on'){ \Yii::$app->redis->set($redis_name,1); }else{ \Yii::$app->redis->set($redis_name,0); } } return [ 'code' => 0, 'msg' => '保存成功' ]; } public function search() { $content = Option::getOption($this->key, $this->cx_mch_id); if($this->is_base64_encode($content)) $content = base64_decode($content); return [ 'content' => $content, ]; } private function is_base64_encode($content) { try{ if($content == base64_encode(base64_decode($content))) return true; } catch (\Exception $ex){ } return false; } }