Development

This commit is contained in:
Simon Sessingø
2016-11-26 10:40:42 +01:00
parent aad11ac581
commit 2c5221051e
8 changed files with 165 additions and 186 deletions
+27 -8
View File
@@ -46,6 +46,32 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
}
}
public function matchRegex(Request $request, $url) {
/* Match on custom defined regular expression */
if ($this->regex === null) {
return false;
}
$parameters = [];
if (preg_match($this->regex, $request->getHost() . $url, $parameters) !== false) {
/* Remove global match */
if (count($parameters) > 1) {
$this->setParameters(array_slice($parameters, 1));
//array_shift($parameters);
//$this->parameters = $parameters;
}
return true;
}
return false;
}
/**
* Set url
*
@@ -61,15 +87,8 @@ abstract class LoadableRoute extends Route implements ILoadableRoute
$regex = sprintf(static::PARAMETERS_REGEX_MATCH, $this->paramModifiers[0], $this->paramOptionalSymbol, $this->paramModifiers[1]);
if (preg_match_all('/' . $regex . '/is', $this->url, $matches)) {
$max = count($matches[1]);
for ($i = 0; $i < $max; $i++) {
$this->parameters[$matches[1][$i]] = null;
}
$this->parameters = array_fill_keys($matches[1], null);
}
}
return $this;