Skip to content

可否增加获取路由所有参数的方法? #13

@GHJayce

Description

@GHJayce

例如有路由:path/{paramA}/{paramB},需求是想获取所有的参数,即paramAparamB

但目前只有route方法,只能获取单个路由参数,对应代码如下:

/**
 * Retrieve the data from route parameters.
 */
public function route(string $key, mixed $default = null): mixed
{
    /** @var null|Dispatched $route */
    $route = $this->getAttribute(Dispatched::class);
    if (is_null($route)) {
        return $default;
    }
    return array_key_exists($key, $route->params) ? $route->params[$key] : $default;
}

能否新增routes()方法,获取路由的所有参数?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions