mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Optimizations
- Settings parameter in group method are no longer optional. - Updated README to contain PHP JSON-extension under requirements. - Updated composer.json to include php json extension.
This commit is contained in:
@@ -63,7 +63,7 @@ class CookieTokenProvider implements ITokenProvider
|
||||
public function setToken(string $token): void
|
||||
{
|
||||
$this->token = $token;
|
||||
setcookie(static::CSRF_KEY, $token, (int)((time() + 60) * $this->cookieTimeoutMinutes), '/', ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
|
||||
setcookie(static::CSRF_KEY, $token, (time() + 60) * $this->cookieTimeoutMinutes, '/', ini_get('session.cookie_domain'), ini_get('session.cookie_secure'), ini_get('session.cookie_httponly'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -151,12 +151,10 @@ abstract class Route implements IRoute
|
||||
/* If custom regex is defined, use that */
|
||||
if (isset($this->where[$name]) === true) {
|
||||
$regex = $this->where[$name];
|
||||
} else if ($parameterRegex !== null) {
|
||||
$regex = $parameterRegex;
|
||||
} else {
|
||||
if ($parameterRegex !== null) {
|
||||
$regex = $parameterRegex;
|
||||
} else {
|
||||
$regex = $this->defaultParameterRegex ?? static::PARAMETERS_DEFAULT_REGEX;
|
||||
}
|
||||
$regex = $this->defaultParameterRegex ?? static::PARAMETERS_DEFAULT_REGEX;
|
||||
}
|
||||
|
||||
$regex = sprintf('((\/|\-)(?P<%2$s>%3$s))%1$s', $parameters[2][$key], $name, $regex);
|
||||
|
||||
@@ -261,7 +261,7 @@ class SimpleRouter
|
||||
* @return RouteGroup
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function group(array $settings = [], \Closure $callback): IGroupRoute
|
||||
public static function group(array $settings, \Closure $callback): IGroupRoute
|
||||
{
|
||||
if (\is_callable($callback) === false) {
|
||||
throw new InvalidArgumentException('Invalid callback provided. Only functions or methods supported');
|
||||
|
||||
Reference in New Issue
Block a user