Skip to content

Commit

Permalink
replace all '\$_POST\[(.+?)\]' matches
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Sep 26, 2023
1 parent 52d528a commit a850947
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/Form/Control/DropdownCascade.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ protected function init(): void
$this->cascadeFrom = $this->form->getControl($this->cascadeFrom);
}

$cascadeFromValue = isset($_POST[$this->cascadeFrom->name])
? $this->getApp()->uiPersistence->typecastLoadField($this->cascadeFrom->entityField->getField(), $_POST[$this->cascadeFrom->name])
$cascadeFromValue = $this->getApp()->hasRequestPostParam($this->cascadeFrom->name)
? $this->getApp()->uiPersistence->typecastLoadField($this->cascadeFrom->entityField->getField(), $this->getApp()->getRequestPostParam($this->cascadeFrom->name))
: $this->cascadeFrom->entityField->get();

$this->model = $this->cascadeFrom->model ? $this->cascadeFrom->model->ref($this->reference) : null;
Expand Down
8 changes: 4 additions & 4 deletions src/Form/Control/Multiline.php
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ protected function init(): void

// load the data associated with this input and validate it
$this->form->onHook(Form::HOOK_LOAD_POST, function (Form $form, array &$postRawData) {
$this->rowData = $this->typeCastLoadValues($this->getApp()->decodeJson($_POST[$this->shortName]));
$this->rowData = $this->typeCastLoadValues($this->getApp()->decodeJson($this->getApp()->getRequestPostParam($this->shortName)));
if ($this->rowData) {
$this->rowErrors = $this->validate($this->rowData);
if ($this->rowErrors) {
Expand Down Expand Up @@ -676,14 +676,14 @@ protected function renderView(): void
*/
private function outputJson(): void
{
switch ($_POST['__atkml_action']) {
switch ($this->getApp()->getRequestPostParam('__atkml_action')) {
case 'update-row':
$entity = $this->createDummyEntityFromPost($this->model);
$expressionValues = array_merge($this->getExpressionValues($entity), $this->getCallbackValues($entity));
$this->getApp()->terminateJson(['success' => true, 'expressions' => $expressionValues]);
// no break - expression above always terminate
case 'on-change':
$rowsRaw = $this->getApp()->decodeJson($_POST['rows']);
$rowsRaw = $this->getApp()->decodeJson($this->getApp()->getRequestPostParam('rows'));
$response = ($this->onChangeFunction)($this->typeCastLoadValues($rowsRaw), $this->form);
$this->renderCallback->terminateAjax($this->renderCallback->getAjaxec($response));
// TODO JsCallback::terminateAjax() should return never
Expand Down Expand Up @@ -727,7 +727,7 @@ private function createDummyEntityFromPost(Model $model): Model

$field = $entity->getField($fieldName);

$value = $this->getApp()->uiPersistence->typecastLoadField($field, $_POST[$fieldName]);
$value = $this->getApp()->uiPersistence->typecastLoadField($field, $this->getApp()->getRequestPostParam($fieldName));
if ($field->isEditable()) {
try {
$field->required = false;
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Control/Upload.php
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public function onDelete(\Closure $fx): void
$this->hasDeleteCb = true;
if ($this->getApp()->tryGetRequestPostParam('fUploadAction') === self::DELETE_ACTION) {
$this->cb->set(function () use ($fx) {
$fileId = $_POST['fUploadId'];
$fileId = $this->getApp()->getRequestPostParam('fUploadId');

$jsRes = $fx($fileId);
if ($jsRes !== null) { // @phpstan-ignore-line https://github.com/phpstan/phpstan/issues/9388
Expand Down
2 changes: 1 addition & 1 deletion src/JsCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public function set($fx = null, $args = null)

$values = [];
foreach (array_keys($this->args) as $key) {
$values[] = $_POST[$key];
$values[] = $this->getApp()->getRequestPostParam($key);
}

$response = $fx($chain, ...$values);
Expand Down
10 changes: 5 additions & 5 deletions src/JsSortable.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,11 @@ protected function init(): void
*/
public function onReorder(\Closure $fx): void
{
$this->set(static function () use ($fx) {
$sortOrders = explode(',', $_POST['order']);
$source = $_POST['source'];
$newIndex = (int) $_POST['newIndex'];
$origIndex = (int) $_POST['origIndex'];
$this->set(function () use ($fx) {
$sortOrders = explode(',', $this->getApp()->getRequestPostParam('order'));
$source = $this->getApp()->getRequestPostParam('source');
$newIndex = (int) $this->getApp()->getRequestPostParam('newIndex');
$origIndex = (int) $this->getApp()->getRequestPostParam('origIndex');

return $fx($sortOrders, $source, $newIndex, $origIndex);
});
Expand Down
2 changes: 1 addition & 1 deletion src/VueComponent/InlineEdit.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function setModel(Model $entity): void

if ($this->autoSave && $this->model->isLoaded()) {
$this->cb->set(function () {
$postValue = $_POST['value'];
$postValue = $this->getApp()->getRequestPostParam('value');
try {
$this->model->set($this->fieldName, $this->getApp()->uiPersistence->typecastLoadField($this->model->getField($this->fieldName), $postValue));
$this->model->save();
Expand Down

0 comments on commit a850947

Please sign in to comment.