- Added some new request method (get, post, cookie & server).
- Fixed the Title extension
This commit is contained in:
parent
2df950a054
commit
0e201b77f2
|
@ -29,7 +29,10 @@ class TitleExtension implements Extension {
|
|||
return $this->title;
|
||||
}
|
||||
else {
|
||||
$this->title = $set;
|
||||
# Fixed a bug where template inheritance was rewriting title
|
||||
if ( empty($this->title) ) {
|
||||
$this->title = $set;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
|
|
|
@ -33,24 +33,24 @@ class Request implements Extension {
|
|||
$context->pushFunction("post", [ $this, 'post' ]);
|
||||
}
|
||||
|
||||
public function cookie(string $variableName)
|
||||
public function cookie(? string $variableName = null)
|
||||
{
|
||||
return static::arrayGet($this->request->getCookieParams(), $variableName);
|
||||
return $variableName === null ? $this->request->getCookieParams() : static::arrayGet($this->request->getCookieParams(), $variableName);
|
||||
}
|
||||
|
||||
public function get(string $variableName)
|
||||
public function get(? string $variableName = null)
|
||||
{
|
||||
return static::arrayGet($this->request->getQueryParams(), $variableName);
|
||||
return $variableName === null ? $this->request->getQueryParams() : static::arrayGet($this->request->getQueryParams(), $variableName);
|
||||
}
|
||||
|
||||
public function post(string $variableName)
|
||||
public function post(? string $variableName = null)
|
||||
{
|
||||
return static::arrayGet($this->request->getParsedBody(), $variableName);
|
||||
return $variableName === null ? $this->request->getParsedBody() : static::arrayGet($this->request->getParsedBody(), $variableName);
|
||||
}
|
||||
|
||||
public function server(string $variableName)
|
||||
public function server(? string $variableName = null)
|
||||
{
|
||||
return static::arrayGet($this->request->getServerParams(), $variableName);
|
||||
return $variableName === null ? $this->request->getServerParams() : static::arrayGet($this->request->getServerParams(), $variableName);
|
||||
}
|
||||
|
||||
public static function arrayGet(array $array, string $path, string $delimiter = '.')
|
||||
|
|
Loading…
Reference in New Issue