mirror of
https://github.com/openvk/chandler.git
synced 2025-02-08 23:39:31 +03:00
Add SimplePresenter::findParam
This commit is contained in:
parent
65da4abe33
commit
f55f6d445d
1 changed files with 18 additions and 2 deletions
|
@ -166,8 +166,9 @@ abstract class SimplePresenter implements IPresenter
|
||||||
return $_GET[$index] ?? NULL;
|
return $_GET[$index] ?? NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function postParam(string $index): ?string
|
protected function postParam(string $index, bool $csrfCheck = true): ?string
|
||||||
{
|
{
|
||||||
|
if($csrfCheck)
|
||||||
$this->assertNoCSRF();
|
$this->assertNoCSRF();
|
||||||
|
|
||||||
return $_POST[$index] ?? NULL;
|
return $_POST[$index] ?? NULL;
|
||||||
|
@ -186,6 +187,21 @@ abstract class SimplePresenter implements IPresenter
|
||||||
return $GLOBALS["jsonInputCache"][$index] ?? NULL;
|
return $GLOBALS["jsonInputCache"][$index] ?? NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function findParam(string $index, array $searchIn = ["json", "post", "query"]): ?string
|
||||||
|
{
|
||||||
|
$res = NULL;
|
||||||
|
foreach($searchIn as $search) {
|
||||||
|
if($search === "json")
|
||||||
|
$res = $this->jsonParam($index) ?? $res;
|
||||||
|
else if($search === "post")
|
||||||
|
$res = $this->postParam($index, false) ?? $res;
|
||||||
|
else if($search === "query")
|
||||||
|
$res = $this->queryParam($index) ?? $res;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $res;
|
||||||
|
}
|
||||||
|
|
||||||
protected function checkbox(string $name): bool
|
protected function checkbox(string $name): bool
|
||||||
{
|
{
|
||||||
return ($this->postParam($name) ?? "off") === "on";
|
return ($this->postParam($name) ?? "off") === "on";
|
||||||
|
|
Loading…
Reference in a new issue