本文整理汇总了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();
}