fix: extract and pass URI template variables to resource handlers (#123)
This commit is contained in:
parent
f41ea86608
commit
55f860808c
1 changed files with 19 additions and 29 deletions
|
|
@ -57,18 +57,17 @@ class ResourceTemplateReference extends ElementReference
|
|||
|
||||
public function matches(string $uri): bool
|
||||
{
|
||||
if (preg_match($this->uriTemplateRegex, $uri, $matches)) {
|
||||
$variables = [];
|
||||
foreach ($this->variableNames as $varName) {
|
||||
if (isset($matches[$varName])) {
|
||||
$variables[$varName] = $matches[$varName];
|
||||
}
|
||||
}
|
||||
return 1 === preg_match($this->uriTemplateRegex, $uri);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
/** @return array<string, mixed> */
|
||||
public function extractVariables(string $uri): array
|
||||
{
|
||||
$matches = [];
|
||||
|
||||
return false;
|
||||
preg_match($this->uriTemplateRegex, $uri, $matches);
|
||||
|
||||
return array_filter($matches, fn ($key) => \in_array($key, $this->variableNames), \ARRAY_FILTER_USE_KEY);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Reference in a new issue