-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ENH] refactor http input to trigger each specific action, from GET, POST, PUT and FILES #187
base: master
Are you sure you want to change the base?
Conversation
@@ -36,7 +36,7 @@ function home() | |||
*/ | |||
function changeLang() | |||
{ | |||
Session::put('lang', Input::get("lang")); | |||
Session::put('lang', Input::post("lang")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this example could be on another commit of example
$object_data = self::put(); | ||
if (isset($_POST[$item])) { | ||
return $_POST[$item]; | ||
} else if (isset($_GET[$item])) { | ||
return $_GET[$item]; | ||
} else if (isset($object_data[$item])) { | ||
return $object_data[$item]; | ||
} | ||
return null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This approach make everything clean
$form_data_fragmentation = []; | ||
$explode = explode("\r", implode("\r", explode("\n", $file_input))); | ||
$len_Arr = count($explode); | ||
for ($i = 1; $i < $len_Arr; $i++) { | ||
if (!strchr($explode[$i], "----------------------------")) { | ||
if (strlen($explode[$i]) > 0) { | ||
$replaced = str_replace("Content-Disposition: form-data; name=", "", $explode[$i]); | ||
array_push($fragma, $replaced); | ||
$form_data_fragmentation[] = $replaced; | ||
} | ||
} | ||
} | ||
$len_object = count($fragma); | ||
$len_object = count($form_data_fragmentation); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Load data from form-data should be revised, refactoring and validate while load form-data submission.
The process is not clean and testable.
if (isset($_POST[$item])) { | ||
return $_POST[$item]; | ||
} else if (isset($self_put[$item])) { | ||
return $self_put[$item]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is better to have a form-data method to avoid confusion.
We used to used
Input::get()
method to read data from http requestGET
,POST
andPUT
without any distinction, that lead for some confusion, in case we want to deal with post, put, there was not a specific way to deal with.The approach to have each method for a specific case it makes the module more readable and more mature, and void confusion.