mirror of
https://github.com/skipperbent/simple-php-router.git
synced 2026-06-17 08:47:52 +00:00
Merge branch 'v4-development' of github.com:skipperbent/simple-php-router into v4-development
This commit is contained in:
@@ -484,13 +484,13 @@ SimpleRouter::get('/user/{name}', function ($name) {
|
|||||||
|
|
||||||
// ... do stuff
|
// ... do stuff
|
||||||
|
|
||||||
})->where('name', '[A-Za-z]+');
|
})->where([ 'name' => '[A-Za-z]+' ]);
|
||||||
|
|
||||||
SimpleRouter::get('/user/{id}', function ($id) {
|
SimpleRouter::get('/user/{id}', function ($id) {
|
||||||
|
|
||||||
// ... do stuff
|
// ... do stuff
|
||||||
|
|
||||||
})->where('id', '[0-9]+');
|
})->where([ 'id' => '[0-9]+' ]);
|
||||||
|
|
||||||
SimpleRouter::get('/user/{id}/{name}', function ($id, $name) {
|
SimpleRouter::get('/user/{id}/{name}', function ($id, $name) {
|
||||||
|
|
||||||
|
|||||||
@@ -303,13 +303,22 @@ class InputHandler
|
|||||||
// Append any PHP-input json
|
// Append any PHP-input json
|
||||||
if (strpos(trim($contents), '{') === 0) {
|
if (strpos(trim($contents), '{') === 0) {
|
||||||
$post = json_decode($contents, true);
|
$post = json_decode($contents, true);
|
||||||
|
|
||||||
if ($post !== false) {
|
if ($post !== false) {
|
||||||
$output += $post;
|
$output += $post;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (\count($filter) > 0) ? array_intersect_key($output, array_flip($filter)) : $output;
|
$output = (\count($filter) > 0) ? array_intersect_key($output, array_flip($filter)) : $output;
|
||||||
|
|
||||||
|
foreach ($filter as $filterKey) {
|
||||||
|
if (array_key_exists($filterKey, $output) === false) {
|
||||||
|
$output[$filterKey] = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $output;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -345,4 +354,4 @@ class InputHandler
|
|||||||
$this->file[$key] = $item;
|
$this->file[$key] = $item;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class CookieTokenProvider implements ITokenProvider
|
|||||||
public function setToken(string $token): void
|
public function setToken(string $token): void
|
||||||
{
|
{
|
||||||
$this->token = $token;
|
$this->token = $token;
|
||||||
setcookie(static::CSRF_KEY, $token, (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'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class ClassLoader implements IClassLoader
|
|||||||
* @return mixed
|
* @return mixed
|
||||||
* @throws NotFoundHttpException
|
* @throws NotFoundHttpException
|
||||||
*/
|
*/
|
||||||
public function loadClosure(\Closure $closure, array $parameters)
|
public function loadClosure(Callable $closure, array $parameters)
|
||||||
{
|
{
|
||||||
if ($this->useDependencyInjection === true) {
|
if ($this->useDependencyInjection === true) {
|
||||||
$container = $this->getContainer();
|
$container = $this->getContainer();
|
||||||
@@ -115,4 +115,4 @@ class ClassLoader implements IClassLoader
|
|||||||
return $this->useDependencyInjection;
|
return $this->useDependencyInjection;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -7,6 +7,6 @@ interface IClassLoader
|
|||||||
|
|
||||||
public function loadClass(string $class);
|
public function loadClass(string $class);
|
||||||
|
|
||||||
public function loadClosure(\Closure $closure, array $parameters);
|
public function loadClosure(Callable $closure, array $parameters);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user