本文整理匯總了PHP中Symfony\Component\HttpFoundation\JsonResponse::sendContent方法的典型用法代碼示例。如果您正苦於以下問題:PHP JsonResponse::sendContent方法的具體用法?PHP JsonResponse::sendContent怎麽用?PHP JsonResponse::sendContent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Symfony\Component\HttpFoundation\JsonResponse
的用法示例。
在下文中一共展示了JsonResponse::sendContent方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: run
/**
* Ejecuta todo las configuraciones
* @return JsonResponse
*/
public function run()
{
$request = Request::createFromGlobals();
$request->getPathInfo();
$jsonResponse = new JsonResponse();
if ($request->getMethod() == 'POST') {
$this->action = $this->sanitize($request->request->get('action'));
$path = $this->sanitize($request->request->get('path'));
if ($this->validPath($path) == false) {
$result = array("query" => "BE_RUN_NOT_VALID %s", "params" => array($path));
$this->setInfo(array("msg" => $result));
if ($this->config['debug']) {
$this->_log(__METHOD__ . ' - No valido $path: ' . $path);
}
} else {
if ($this->action === 'getfolder') {
$folders = $this->getAllFiles($path);
if (is_array($folders)) {
$this->setInfo(array("data" => $folders));
}
} elseif ($this->action === 'uploadfile') {
$files = $this->uploadAll($request->files->get('file'), $path);
if ($files) {
$this->setInfo(array("data" => $files));
}
} elseif ($this->action === 'newfolder') {
$name = $this->sanitize($request->request->get('name'));
$this->newFolder($name, $path);
} elseif ($this->action === 'renamefile') {
$nameold = $this->sanitize($request->request->get('nameold'));
$namenew = $this->sanitize($request->request->get('name'));
$this->rename($nameold, $namenew, $path);
} elseif ($this->action === 'movefile') {
$nameold = $this->sanitize($request->request->get('nameold'));
$namenew = $this->sanitize($request->request->get('name'));
$this->move($nameold, $namenew, $path);
} elseif ($this->action === 'deletefile') {
$name = $request->request->get('name');
$this->delete($name, $path);
} else {
$this->setInfo(array("status" => 0));
}
}
} elseif ($request->getMethod() == 'GET') {
$this->action = $this->sanitize($request->query->get('action'));
$path = $this->sanitize($request->query->get('path'));
$name = $this->sanitize($request->query->get('name'));
if ($this->validPath($path) == false) {
$result = array("query" => "BE_RUN_NOT_VALID %s", "params" => array($path));
$this->setInfo(array("msg" => $result));
if ($this->config['debug']) {
$this->_log(__METHOD__ . ' - No valido $path: ' . $path);
}
} else {
if ($this->action === 'download') {
$this->download($name, $path);
}
}
}
$jsonResponse->setData($this->info);
return $jsonResponse->sendContent();
}