更新自定义菜单
@method updateMenu
@since 0.0.1
@return {boolean}
@example \Yii::$app->wechat->updateMenu();
558879
public function updateMenu() {
		$data = $this->getData('/cgi-bin/menu/create', [
			'access_token' => $this->getAccessToken(),
		], Json::encode(['button' => WechatMenu::getMenu($this->app->appid)]));

		return $this->errcode == 0;
	}
781392
public function getApp()
	{
		if(! self::$_app instanceof Application){
			self::$_app = new Application(Yii::$app->params['WECHAT']);
		}
		return self::$_app;
	}
20882
function save()
    {
        $this->_save = false;
        if ($this->_change == 0 or $this->_change == 1)
        {
            if ($this->db->insert($this->_data, $this->table) === false)
            {
                return false;
            }
            //改变状态
            $this->_change = 1;
            $this->_current_id = $this->db->lastInsertId();
        }
        elseif ($this->_change == 2)
        {
            $update = $this->_update;
            unset($update[$this->primary]);
            if ($this->db->update($this->_current_id, $update, $this->table, $this->primary) === false)
            {
                return false;
            }
        }
        $this->notify();
        return true;
    }
1185214
public function actionCreate()
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['create']);
        }
        try{
            $model = new Menu;

            if ($model->load(Yii::$app->request->post()) && $model->save()) {
                Helper::invalidate();
                return ["success"=> true];
            } else {
                return ["success"=> false];
            }
        }catch(Exception $e){
            throw new Exception($e);
        }

    }
1012019
public function updateFileInfo()
    {
        $src = $this->src;

        if ($this->cluster instanceof ClusterLocal) {
            if (!\Yii::$app->request->hostInfo) {
                return $this;
            }

            $src = \Yii::$app->request->hostInfo . $this->src;
        }
        //Елси это изображение
        if ($this->isImage()) {
            if (extension_loaded('gd')) {
                list($width, $height, $type, $attr) = getimagesize($src);
                $this->image_height = $height;
                $this->image_width = $width;
            }
        }

        $this->save();
        return $this;
    }
969858
private function addApp ()
		{
			$appNew = new Apiapp();
			if (Yii::$app->request->post('method') == 'apiapp')
			{
				$post = Yii::$app->request->post();

				if ($post[ 'id' ])
					$appNew = Apiapp::findOne($post[ 'id' ]);

				$appNew->setAttributes([ 'name' => $post[ 'name' ] ]);
				$appNew->token = StringHelper::random(16);
				if ($appNew->validate())
				{
					$appNew->save();
					if (!$post[ 'id' ])
						Yii::$app->session->set('viewID', $appNew->id);
					$url = Yii::$app->request->referrer . '#' . $appNew->name;
					$appNew->setAttributes([ 'name' => '', 'token' => '' ]);
					LogManager::info(Yii::tr('User {user} has created API application {name}.', [ 'user' => Html::a(Yii::$app->user->identity->name, Url::toRoute([ 'user/view', 'id' => Yii::$app->user->id ])), 'name' => $post[ 'name' ] ]));

					Yii::$app->response->redirect($url);
					Yii::$app->end();
				}
			}

			return $appNew;
		}
835698
public function actionGetMenus()
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['index']);
        }
        try{
            return Menu::getMenuSource();
        }catch(Exception $e){
            throw new Exception($e);
        }
    }
53206
public
    function actionProjectupdate()
    {
        $id = \Yii::$app->request->get('id');
        if (!isset($id)) {
            return new NotFoundHttpException('The requested project does not exist.');
        }

        $model = $this->findProjectmodel($id);
        if (!$model instanceof Project) {
            return false;
        }

        if ($model->load(Yii::$app->request->post()) /*&& $model->setautovalues()*/ && $model->save()) {
            return $this->redirect(['projectview', 'id' => $model->id]);
        } else {
            return $this->render('projectupdate', [
                'model' => $model,
            ]);
        }
    }
149457
public function getMenuList()
    {
        $result = $this->httpRaw(self::WECHAT_MENU_GET_URL . 'access_token=' . $this->getAccessToken());
        return isset($result['menu']['button']) ? $result['menu']['button'] : false;
    }
895624
def update(self, *args):
        """"""
        if self.smart:
            self._icon.show(self.has_menu())
        else:
            self._icon.show(True)
817588
public function doUpdate( App $app ) {
		$update = function () use ( $app ) {
			if ( ! $app->nav_menus ) {
				return FALSE;
			}
			if ( ! is_array( $app->nav_menus ) ) {
				throw new ConfigException(
				    __("Value of 'nav_menus' parameter in '*.config.json' must be an object.", 'wpf') );
			}
			register_nav_menus( $app->nav_menus );
		};
		add_action('after_setup_theme', $update );
	}
456232
public function actionUpdate($id)
    {
        $model = $this->findModel($id);

        if ($model->load(Yii::$app->request->post()) && $model->save()) {
            Yii::$app->getSession()->setFlash('success', '修改成功');
            return \myzero1\layui\helpers\Tool::redirectParent(['index']);
        } else {
            return $this->render('update', [
                'model' => $model,
            ]);
        }
    }
1250522
public function actionSave()
    {
        $url_id = \Yii::$app->request->post('url_id');
        $menu_id = \Yii::$app->request->post('menu_id');
        $name = \Yii::$app->request->post('name');
        $alias = \Yii::$app->request->post('alias');
        $route = \Yii::$app->request->post('route');
        $method = \Yii::$app->request->post('method');
        $host = \Yii::$app->request->post('host');
        $enable_rule = \Yii::$app->request->post('enable_rule');
        $note = \Yii::$app->request->post('note');
        $status = \Yii::$app->request->post('status');

        if (!$alias) {
            // 自动生成别名
            if (strpos($route, '/') === 0) {
                $tempRoute = substr($route, 1, strlen($route));
            } else {
                $tempRoute = $route;
            }
            $alias = join('.', StringHelper::explode($tempRoute, '/', true, true));
        }
        $methodStr = '';
        if (is_array($method)) {
            $method = array_filter($method, function ($value) {
                return in_array($value, ['GET', 'HEAD', 'POST', 'PUT', 'PATCH', 'DELETE', 'OPTIONS']);
            });
            $methodStr = join(',', $method);
        }
        $saveData = [
            'name' => $name,
            'alias' => $alias,
            'route' => $route,
            'method' => $methodStr,
            'host' => $host,
            'enable_rule' => $enable_rule,
            'note' => $note,
            'status' => $status,
        ];
        $obj = null;
        if ($url_id) {
            $obj = DpAdminMenuUrl::find()
                ->findByUrlId($url_id)
                ->one();
            if (!$obj) {
                return $this->renderError('保存失败，记录不存在！');
            }
        } else {
            if ($alias) {
                $obj = DpAdminMenuUrl::find()
                    ->findByAlias($alias)
                    ->one();
            }
            if (!$obj) {
                $obj = new DpAdminMenuUrl();
            }
        }
        $obj->setAttributes($saveData);
        if (!$obj->save()) {
            foreach ($obj->getErrors() as $error) {
                foreach ($error as $message) {
                    return [
                        'success' => false,
                        'msg' => $message,
                    ];
                }
            }
        }
        if ($menu_id) {
            if (!DpAdminMenu::getByMenuId($menu_id)) {
                return $this->renderError('菜单不存在');
            } else {
                $linkObj = new DpAdminMenuUrlRelation();
                $linkObj->setAttributes([
                    'menu_id' => $menu_id,
                    'url_id' => $obj->url_id,
                    'status' => DpAdminMenuUrlRelation::STATUS_ACTIVE,
                ]);
                if (!$linkObj->save()) {
                    foreach ($obj->getErrors() as $error) {
                        foreach ($error as $message) {
                            return [
                                'success' => false,
                                'msg' => $message,
                            ];
                        }
                    }
                }
            }
        }

        return $this->renderSuccess('保存成功');
    }
1151597
public function actionUpdate($id)
    {
        $request = \Yii::$app->request;
        if ($request->getIsOptions()) {
            return $this->ResponseOptions($this->verbs()['update']);
        }
        if($model = $this->findModel($id)){
            //($model->save());die();
            if ($model->load(Yii::$app->request->post())&& $model->save()) {
                //Helper::invalidate();

                return ['success'=>true];
            }else {
                throw new \yii\web\ServerErrorHttpException();
            }
        }
        throw new \yii\web\ServerErrorHttpException();
    }
1036741
public function createAdminMenu() {
        $connection = \Yii::$app->db;
        $query = new Query;
        if(!$this->singleMenu) {
            $menu_name = $this->friendly($this->getController());
            $menu = $query->from('AdminMenu')
                ->where('internal=:internal', [':internal'=>$this->menu])
                ->one();

            if(!$menu) {
                $query = new Query;
                // compose the query
                $last_main_menu = $query->from('AdminMenu')
                    ->where('AdminMenu_id IS NULL')
                    ->orderby('order DESC')          
                    ->one();

                $this->insert('AdminMenu', [
                    "name" => $this->menu,
                    "internal" => $this->menu,
                    "url" => '',
                    "ap" => 'read::'.$this->getController(),
                    "order" => $last_main_menu ? $last_main_menu['order'] + 1 : 1
                ]);
                $menu_id = $connection->getLastInsertID();
            } else {
                $menu_id = $menu['id'];
            }
        } else {
            $menu_id = NULL;
            $menu_name = $this->menu;
        }
        $query = new Query;

        $last_menu = $query->from('AdminMenu')
                ->from('AdminMenu')
                ->where('AdminMenu_id=:AdminMenu_id', [':AdminMenu_id'=>$menu_id])
                ->orderby('order DESC')
                ->one();

        $this->insert('AdminMenu', [
            "AdminMenu_id" => $menu_id,
            "name" => $menu_name,
            "internal" => $this->getController() . 'Controller',
            "url" => ($this->module ? '/' . $this->module : '' ) . '/'. strtolower(trim(preg_replace("([A-Z])", "-$0", $this->getController()), '-')).'/',
            "ap" => 'read::'.$this->getController(),
            "order" => $last_menu ? $last_menu['order'] + 1 : 1
        ]);
    }
1162678
public function getMenuInfo()
    {
        $result = $this->httpGet(self::WECHAT_MENU_INFO_GET_PREFIX, [
            'access_token' => $this->getAccessToken()
        ]);
        return !array_key_exists('errcode', $result) ? $result : false;
    }
504671
function () {
            var self = this, cur = self, last;
            do {
                // 沿着 menu，menuitem 链
                last = cur;
                cur = cur.get('parent');
            } while (cur && (cur.isMenuItem || cur.isMenu));
            return last;
        }