当前位置: 首页>>代码示例>>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;未经允许,请勿转载。