yii\rest\UrlRule::createRule PHP Method

createRule() protected method

Creates a URL rule using the given pattern and action.
protected createRule ( string $pattern, string $prefix, string $action ) : yii\web\UrlRuleInterface
$pattern string
$prefix string
$action string
return yii\web\UrlRuleInterface
    protected function createRule($pattern, $prefix, $action)
    {
        $verbs = 'GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS';
        if (preg_match("/^((?:({$verbs}),)*({$verbs}))(?:\\s+(.*))?\$/", $pattern, $matches)) {
            $verbs = explode(',', $matches[1]);
            $pattern = isset($matches[4]) ? $matches[4] : '';
        } else {
            $verbs = [];
        }
        $config = $this->ruleConfig;
        $config['verb'] = $verbs;
        $config['pattern'] = rtrim($prefix . '/' . strtr($pattern, $this->tokens), '/');
        $config['route'] = $action;
        if (!in_array('GET', $verbs)) {
            $config['mode'] = \yii\web\UrlRule::PARSING_ONLY;
        }
        $config['suffix'] = $this->suffix;
        return Yii::createObject($config);
    }