當前位置: 首頁>>代碼示例>>PHP>>正文


PHP JsonResponse::sendContent方法代碼示例

本文整理匯總了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();
 }
開發者ID:guillermomartinez,項目名稱:filemanager-php,代碼行數:66,代碼來源:Filemanager.php


注:本文中的Symfony\Component\HttpFoundation\JsonResponse::sendContent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。