protected function UploaderServlet::getReq in N1ED - Visual editor as CKEditor plugin with Bootstrap support 8.2
Gets a request.
1 call to UploaderServlet::getReq()
- UploaderServlet::doPost in src/
Flmngr/ FileUploaderServer/ servlet/ UploaderServlet.php - Processes POST HTTP request.
File
- src/
Flmngr/ FileUploaderServer/ servlet/ UploaderServlet.php, line 56
Class
- UploaderServlet
- Uploader servlet (ported from Java). Stores available action processors, routes request to one of them and returns JSON formed by request processor.
Namespace
Drupal\n1ed\Flmngr\FileUploaderServer\servletCode
protected function getReq(RequestStack $request_stack, $files) {
$req = NULL;
try {
$data = $request_stack
->getCurrentRequest()->request
->get('data') ?? json_encode([
'action' => 'upload',
]);
$req = $this->json
->fromJson($data);
if ($this->config
->isTestAllowed()) {
if (array_key_exists("testServerConfig", $req)) {
$this->config
->setTestConfig($req->testServerConfig);
}
if (array_key_exists("testClearAllFiles", $req)) {
$this
->clearAllFiles();
}
}
} catch (Exception $e) {
error_log($e);
return NULL;
}
if (array_key_exists('file', $files) || array_key_exists('upload', $files)) {
$req->file = $files['file'] ?? $files['upload'];
$req->fileName = $req->file['name'];
$req->fileSize = $req->file['size'];
}
return $req;
}