添加菜单
@param array $buttons
@param array $matchRule
@return array
@throws \yii\httpclient\Exception
422012
public function add(array $buttons, array $matchRule = [])
    {
        if (!empty($matchRule)) {
            return $this->json(self::API_CONDITIONAL_CREATE,  [
                'button' => $buttons,
                'matchrule' => $matchRule,
            ]);
        }
        return $this->json(self::API_CREATE,['button' => $buttons]);
    }
1060427
public function buttons($buttons = null)
    {
        if (!is_array($buttons)) {
            $buttons = func_get_args();
        }
        $html = '<div class="ccm-buttons well">';
        foreach ($buttons as $_html) {
            $html .= $_html . ' ';
        }
        $html .= '</div>';

        return $html;
    }
1200192
protected function buttonsViewData(FormRuleContext $context)
    {
        $buttonNames = $context->getButtons();

        $buttons = array();
        foreach ($buttonNames as $name) {
            $groups = $context->getGroup($name);

            $buttons[] = array(
                'name' => $name,
                'cancel' => count($groups) === 0,
                'validation_groups' => $groups,
            );
        }

        return $buttons;
    }
35982
public function buttons(...$buttons)
    {
        foreach ($buttons as $button) {
            $this->attributes['buttons'][] = $button instanceof Arrayable ? $button->toArray() : $button;
        }

        return $this;
    }
182547
public function addButtons(array $buttons): self
    {
        foreach ($buttons as $button) {
            if ($button instanceof ElementButton) {
                $this->buttons[] = $button->toArray();
            }
        }

        return $this;
    }
234847
public function addMatchers(array $matchers)
    {
        $this->matchers = \array_merge($this->matchers, $matchers);

        if (isset($this->autoCompleter)) {
            $this->addMatchersToAutoCompleter($matchers);
        }
    }
169385
public function checkRule($url, $match = null, $completeMatch = false)
    {
        if ($dispatch = $this->checkCrossDomain()) {
            // 允许跨域
            return $dispatch;
        }

        // 检查参数有效性
        if (!$this->checkOption($this->option)) {
            return false;
        }

        // 合并分组参数
        $option = $this->mergeGroupOptions();
        $url = $this->urlSuffixCheck($url, $option);

        if (is_null($match)) {
            $match = $this->match($url, $option, $completeMatch);
        }

        if (false !== $match) {
            // 检查前置行为
            if (isset($option['before']) && false === $this->checkBefore($option['before'])) {
                return false;
            }

            return $this->parseRule($this->rule, $this->route, $url, $option, $match);
        }

        return false;
    }
948355
public function addMatcherDriver(MatcherDriver $driver): void
    {
        if (!in_array($driver, $this->drivers, true)) {
            $this->drivers[] = $driver;

            if ($driver->isAvailable()) {
                foreach ($driver->matcherClassNames() as $className) {
                    $this->driverIndex[$className] = $driver;
                }
            }
        }
    }
786510
protected function attachRules(&$grid, array $rules = null)
    {
        $fieldsets = $grid->fieldsets();

        if (!empty(Input::get('ajax')) && Request::ajax() && !is_null($key = Input::get('key'))) {
            $name      = Crypt::decrypt($key);
            $fieldsets = $this->fieldPermissionAdapter->resolveFields($fieldsets, $name);
            if (empty($fieldsets)) {
                return false;
            }
        }
        $controls = [];
        foreach ($fieldsets as $fieldset) {
            foreach ($fieldset->controls as $control) {
                array_push($controls, method_exists($control, 'getName') ? $control->getType() : $control->name);
            }
        }

        $rulesDispatcher = new RulesDispatcher($rules);
        $grid->rules($rulesDispatcher->getSupported($controls));

        foreach ($fieldsets as $fieldset) {
            foreach ($fieldset->controls as $control) {
                $validation = $this->resolveRules($control, $rules);

                if (method_exists($control, 'setAttributes')) {
                    $control->setAttributes(array_merge($control->getAttributes(), $validation));
                } else {
                    $control->attributes = array_merge($control->attributes, $validation);
                }
            }
        }
    }
1135321
public function addButton(Button $button)
    {
        if ( ! $this->buttons instanceof ArrayIterator) {
            $this->buttons = new ArrayIterator();
        }

        $this->buttons->push($button);

        return $this;
    }
1165589
public function createMenu(array $buttons)
    {
        $result = $this->httpRaw(self::WECHAT_MENU_CREATE_URL . 'access_token=' . $this->getAccessToken(), [
            'button' => $buttons
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
1095888
protected function fillForm($buttonText, $inputs = [])
    {
        if (! is_string($buttonText)) {
            $inputs = $buttonText;

            $buttonText = null;
        }

        return $this->getForm($buttonText)->setValues($inputs);
    }
1303061
private function addMatchersToAutoCompleter(array $matchers)
    {
        foreach ($matchers as $matcher) {
            if ($matcher instanceof ContextAware) {
                $matcher->setContext($this->context);
            }
            $this->autoCompleter->addMatcher($matcher);
        }
    }
117442
public function appendToXml(&$xmlRule)
    {
        $xmlAction = $xmlRule->addChild($this->action);
        $xmlAction->addChild($this->timeSpec, $this->timeValue);
    }
1247451
public function addLexerRule($rulename, $rule)
	{
		$this->rules[$rulename] = [];
		$this->rules[$rulename][] = $rule; 
	}
316545
protected function createBindModel($bindModel, $matches)
    {
        foreach ($bindModel as $key => $val) {
            if ($val instanceof \Closure) {
                $result = $this->app->invokeFunction($val, $matches);
            } else {
                $fields = explode('&', $key);

                if (is_array($val)) {
                    list($model, $exception) = $val;
                } else {
                    $model = $val;
                    $exception = true;
                }

                $where = [];
                $match = true;

                foreach ($fields as $field) {
                    if (!isset($matches[$field])) {
                        $match = false;
                        break;
                    } else {
                        $where[] = [$field, '=', $matches[$field]];
                    }
                }

                if ($match) {
                    $query = strpos($model, '\\') ? $model::where($where) : $this->app->model($model)->where($where);
                    $result = $query->failException($exception)->find();
                }
            }

            if (!empty($result)) {
                // 注入容器
                $this->app->instance(get_class($result), $result);
            }
        }
    }
364788
protected function determineMatches(Matcher $matcher, Result $control, array $trials = [])
    {
        foreach ($trials as $trial) {
            if ($matcher->match($control->getValue(), $trial->getValue())) {
                $trial->setMatch(true);
            }
        }
    }