maj+ header

This commit is contained in:
2018-08-22 14:46:33 +02:00
parent 28c9e9d76f
commit 3fc62ab1f1
443 changed files with 24198 additions and 6201 deletions
+4 -5
View File
@@ -178,7 +178,7 @@ class Route
*/
public function withGravParam($param, $value)
{
return $this->withParam('gravParams', $param, $value);
return $this->withParam('gravParams', $param, null !== $value ? (string)$value : null);
}
/**
@@ -222,17 +222,16 @@ class Route
protected function withParam($type, $param, $value)
{
$oldValue = isset($this->{$type}[$param]) ? $this->{$type}[$param] : null;
$newValue = null !== $value ? (string)$value : null;
if ($oldValue === $newValue) {
if ($oldValue === $value) {
return $this;
}
$new = clone $this;
if ($newValue === null) {
if ($value === null) {
unset($new->{$type}[$param]);
} else {
$new->{$type}[$param] = $newValue;
$new->{$type}[$param] = $value;
}
return $new;
@@ -28,6 +28,23 @@ class RouteFactory
return new Route($parts);
}
public static function createFromString($path)
{
$path = ltrim($path, '/');
$parts = [
'path' => $path,
'query' => '',
'query_params' => [],
'grav' => [
'root' => self::$root,
'language' => self::$language,
'route' => $path,
'params' => ''
],
];
return new Route($parts);
}
public static function getRoot()
{
return self::$root;