- Added a new {% block ... %} token

- Added a new {% php ... %} token
- Fixed a bug with an OR if foreach is empty
This commit is contained in:
Dave Mc Nicoll committed 2020-03-30 12:13:02 -04:00
1 parent 0e201b77f2
commit 404d1f4359
9 files changed
+143 -22

No files matched your search

+8 -8
View File
@@ -33,24 +33,24 @@ class Request implements Extension {
$context->pushFunction("post", [ $this, 'post' ]);
}
public function cookie(? string $variableName = null)
public function cookie(? string $variableName = null, $default = null)
{
return $variableName === null ? $this->request->getCookieParams() : static::arrayGet($this->request->getCookieParams(), $variableName);
return $variableName === null ? $this->request->getCookieParams() : static::arrayGet($this->request->getCookieParams(), $variableName) ?? $default;
}
public function get(? string $variableName = null)
public function get(? string $variableName = null, $default = null)
{
return $variableName === null ? $this->request->getQueryParams() : static::arrayGet($this->request->getQueryParams(), $variableName);
return $variableName === null ? $this->request->getQueryParams() : static::arrayGet($this->request->getQueryParams(), $variableName) ?? $default;
}
public function post(? string $variableName = null)
public function post(? string $variableName = null, $default = null)
{
return $variableName === null ? $this->request->getParsedBody() : static::arrayGet($this->request->getParsedBody(), $variableName);
return $variableName === null ? $this->request->getParsedBody() : static::arrayGet($this->request->getParsedBody(), $variableName) ?? $default;
}
public function server(? string $variableName = null)
public function server(? string $variableName = null, $default = null)
{
return $variableName === null ? $this->request->getServerParams() : static::arrayGet($this->request->getServerParams(), $variableName);
return $variableName === null ? $this->request->getServerParams() : static::arrayGet($this->request->getServerParams(), $variableName) ?? $default;
}
public static function arrayGet(array $array, string $path, string $delimiter = '.')