应用分组信息
@return self
427356
public function applyGroup()
    {
        $url = $this->env->getPathinfo();
        $url = trim($url, '/');
        if (!$this->_routerGroup) {
            return $this;
        }
        //提取第一段为分组信息
        $urls = explode('/', $url);
        $findGroup = false;
        $this->vitex = Vitex::getInstance();
        foreach ($this->_routerGroup as $bundle) {
            /**
             * @var $bundle RouteBundle
             */
            //动态计算分组，支付多级分组
            $groupCount = substr_count($bundle->getPattern(), '/');
            $groupCount = $groupCount + 1;
            $gstr = implode('/', array_slice($urls, 0, $groupCount));
            if ($bundle->getPattern() != $gstr) {
                //当绑定分组为 / 时此处有bug
                continue;
            }
            $this->groupurl = $bundle->getPattern();

            //查找所有的路由
            //支持多个分组绑定相同的路由前缀
            //当多个分组绑定相同的路由前缀时如果路由相同则后面注册的路由会覆盖之前的路由
            $routeBundles = $this->_routerGroups[$bundle->getPattern() ?: '/'];
            foreach ($routeBundles as $routeBundle) {
                /**
                 * @var $routeBundle RouteBundle
                 */
                $this->parseGroupMethod($routeBundle->getGroup(), $routeBundle->getAppName());
            }
            $findGroup = true;
            break;
        }

        //没有找到分组信息,查询是否有 / 的分组
        if (false === $findGroup) {
            $rootRouteBundles = isset($this->_routerGroups['/']) ? $this->_routerGroups['/']:null;
            if ($rootRouteBundles) {
                $this->groupurl = '/';
                foreach ($rootRouteBundles as $routeBundle) {
                    /**
                     * @var $routeBundle RouteBundle
                     */
                    $this->parseGroupMethod($routeBundle->getGroup(), $routeBundle->getAppName());
                }
            }
        }
        return $this;
    }
202940
public function remove(): self
    {
        if ($this->_parent) {
            $id = spl_object_hash($this);
            unset($this->_parent->_children[$id]);
            unset($this->_parent);
        }
        return $this;
    }
881325
public function setHeader()
    {
        $args = func_get_args();

        if (is_array($args[0])) {
            foreach ($args[0] as $key => $value)
                $this->headers['headers'][$key] = $value;
        } else {
            $this->headers['headers'][$args[0]] = $args[1];
        }

        return $this;
    }
106949
public function parse()
    {
        if (!$this->checkToken()) {
            return $this->parseRet = array('code' => -1, 'message' => 'Token不正确');
        }

        $attrs = $this->xmlToArray($this->postData);
        if ($this->isEncrypted()) {
            $ret = $this->decryptMsg($attrs['Encrypt']);
            if ($ret['code'] !== 1) {
                return $this->parseRet = $ret;
            }
            $attrs = $this->xmlToArray($ret['xml']);
        }

        $this->attrs = $attrs;
        return $this->parseRet = array('code' => 1, 'message' => '解析成功');
    }
1244601
public function send()
    {
        $this->sendHeaders();
        $this->sendCookies();
        $this->sendContent();

        if (function_exists('fastcgi_finish_request')) {
            fastcgi_finish_request();
        }

        // 重置响应信息，terminate 的时候有可能需要收集响应信息
        $this->reset();

        return $this;
    }
1224280
public function groupBy()
    {
        foreach (func_get_args() as $arg) {
            $this->groups = array_merge((array) $this->groups, is_array($arg) ? $arg : [$arg]);
        }

        return $this;
    }
259721
public function getGroup(): Group {
	
		if (!$this->issetCache('group')) {
			$this->setCache('group', new Group($this->groupId));
		}
	
		return $this->getCache('group');
	
	}
1055256
public function addGroup()
    {
        $conditions = func_get_args();
        $arr        = array();

        foreach ($conditions as $condition) {
            if (is_array($condition) and count($condition) >= 2) {
                $this->add($condition[0], $condition[1], $condition[2]);

                end($this->_conditions);
                $arr[] = array(key($this->_conditions) => current($this->_conditions));
                array_pop($this->_conditions);
            }
        }

        $this->_conditions[] = $arr;

        return $this;
    }
55550
public function name()
    {
        $args = func_get_args();
        $this->names = array_merge($this->names, $this->args_to_array($args));

        return $this;
    }
852575
public function disable(): self
    {
        if (!empty($this->logs)) {
            $this->logs->removeListener($this);
        }

        return $this;
    }
691396
public function optimize()
    {
        $this->optimizeStringField()
            ->optimizeRequiredField()
            ->optimizeDateFields()
            ->optimizeBoolean()
            ->optimizePrimaryKey()
            ->optimizeValidations()
            ->optimizeHtmlType()
            ->addPlaceHolder();

        return $this;
    }
700548
public function command(): self
    {
        $parameters = func_get_args();
        $command = strtoupper(array_shift($parameters));
        $parameters = array_map([$this, 'parameter'], $parameters);

        $this->zpl[] = '^' . $command . implode(',', $parameters);

        return $this;
    }
23010
public function connect(): self
    {
        if ($this->pdoInstance !== null) {
            return $this;
        }

        // Build a database connection if we don't have one connected
        $this->setPdoInstance($this->getAdapter()->connect($this->getAdapterConfig()));

        return $this;
    }
1033433
public function attr()
    {
        $args = func_get_args();

        $this->each(function ($item) use ($args) {
            if (count($args) >= 2) {
                $item->attr($args[0], $args[1]);
            } else {
                $item->attr($args[0]);
            }
        });

        return $this;
    }
235754
public function withCookies(): self
    {
        return tap($this, function ($request) {
            return $this->options = array_merge_recursive($this->options, [
                'cookies' => static::getCookieJar(),
            ]);
        });
    }
1138223
public function api()
    {
        //处理消息
        $this->wechat->server->setMessageHandler(function ($m) {
            $this->m = $m;
            Log::info($m);

            if ($m->Event != 'unsubscribe' && $m->Event != 'LOCATION' && $m->Event != 'VIEW' && $m->Event != 'TEMPLATESENDJOBFINISH') {
                //存上行消息
                $msg = new Message();
                $msg->from_user_name = $m->FromUserName;
                $msg->to_user_name = $m->ToUserName;
                $msg->create_time = $m->CreateTime;
                $msg->msg_type = $m->MsgType;
//                $msg->msg_id = isset($m->MsgId) ? $m->MsgId : 0;
                $msg->content = isset($m->Content) ? $m->Content : '';
                $msg->pic_url = isset($m->PicUrl) ? $m->PicUrl : '';
//                $msg->location_x = isset($m->Location_X) ? $m->Location_X : '';
//                $msg->location_x = isset($m->Location_Y) ? $m->Location_Y : '';
//                $msg->scale = isset($m->Scale) ? $m->Scale : '';
                $msg->label = isset($m->Label) ? $m->Label : '';
                $msg->title = isset($m->Title) ? $m->Title : '';
                $msg->description = isset($m->Description) ? $m->Description : '';
                $msg->url = isset($m->Url) ? $m->Url : '';
                $msg->media_id = isset($m->MediaId) ? $m->MediaId : '';
                $msg->thumb_media_id = $m->ThumbMediaId;
                $msg->event = $m->Event;
                $msg->event_key = $m->EventKey;
                $msg->save();
            }

            //从上行消息中提取关键词
            $key = '';
            switch ($m->MsgType) {
                case 'text':
                    $key = $m->Content;

                    break;
                case 'event':
                    switch ($m->Event) {
                        case 'CLICK':
                            $key = $m->EventKey;
                            break;
                        case 'subscribe'://关注事件
                            UserSns::where('openid', $m->FromUserName)->update(['status' => 0]);
                            break;
                        case 'unsubscribe'://取消关注事件
                            UserSns::where('openid', $m->FromUserName)->update(['status' => 1]);
                            break;
                        case 'SCAN':
                    }
                    break;
            }
            $this->key = $key;
            Log::info($this->key);

//            //帮用户生成本站用户数据
//            if (!$this->reg()) {
//                return 'whops';
//            }

            //判断关注默认回复的关键词
            if ($m->Event == 'subscribe' && empty($m->EventKey)) {
                $this->key = $this->keyFollow;
            }

            //事件key会抽风夹带类似这种的 last_trade_no_4009012001201605306519754434
            if (strpos($m->EventKey, 'last_trade_no') === 0) {
                $this->key = $this->keyFollow;
            }

            //根据关键词处理回复
            $res = FALSE;
            if (!empty($this->key)) {
                $this->r = $this->returnReply();
            } else {
                $this->r = '';
            }

            //入库消息.取关和地理位置不记录

            return $this->r;

        });

        return $this->wechat->server->serve();

    }
652917
public function refresh()
    {
        $behaviors = $this->owner->behaviors();
        $settings = $behaviors[$this->getName()];
        foreach ($settings as $attribute=>$value) {
            if (in_array($attribute, array('class'))) {
                continue;
            }
            $this->$attribute = $value;
        }
        return $this;
    }