当前位置: 首页>>代码示例>>PHP>>正文


PHP JsonHelper::sendJsonHeaders方法代码示例

本文整理汇总了PHP中JsonHelper::sendJsonHeaders方法的典型用法代码示例。如果您正苦于以下问题:PHP JsonHelper::sendJsonHeaders方法的具体用法?PHP JsonHelper::sendJsonHeaders怎么用?PHP JsonHelper::sendJsonHeaders使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在JsonHelper的用法示例。


在下文中一共展示了JsonHelper::sendJsonHeaders方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionExport

 public function actionExport()
 {
     $this->requirePostRequest();
     $result = new ArtVandelay_ExportedDataModel(array('assets' => $this->_exportAssets(), 'categories' => $this->_exportCategories(), 'fields' => $this->_exportFields(), 'globals' => $this->_exportGlobals(), 'sections' => $this->_exportSections(), 'tags' => $this->_exportTags()));
     $json = $result->toJson();
     if (craft()->request->getParam('download')) {
         HeaderHelper::setDownload('export.json', strlen($json));
     }
     JsonHelper::sendJsonHeaders();
     echo $json;
     craft()->end();
 }
开发者ID:jacobnijgh,项目名称:craft-starter,代码行数:12,代码来源:ArtVandelayController.php

示例2: actionRerunTask

 /**
  * Re-runs a failed task.
  *
  * @return null
  */
 public function actionRerunTask()
 {
     $this->requireAjaxRequest();
     $this->requirePostRequest();
     craft()->userSession->requirePermission('accessCp');
     $taskId = craft()->request->getRequiredPost('taskId');
     $task = craft()->tasks->rerunTaskById($taskId);
     if (!craft()->tasks->isTaskRunning()) {
         JsonHelper::sendJsonHeaders();
         craft()->request->close(JsonHelper::encode($task->getInfo()));
         craft()->tasks->runPendingTasks();
     } else {
         $this->returnJson($task->getInfo());
     }
     craft()->end();
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:21,代码来源:TasksController.php

示例3: returnAjaxError

 /**
  * Formats a PHP error into JSON before returning it to the client.
  *
  * @param integer $code error code
  * @param string $message error message
  * @param string $file error file
  * @param string $line error line
  */
 public function returnAjaxError($code, $message, $file, $line)
 {
     if ($this->config->get('devMode')) {
         $outputTrace = '';
         $trace = debug_backtrace();
         // skip the first 3 stacks as they do not tell the error position
         if (count($trace) > 3) {
             $trace = array_slice($trace, 3);
         }
         foreach ($trace as $i => $t) {
             if (!isset($t['file'])) {
                 $t['file'] = 'unknown';
             }
             if (!isset($t['line'])) {
                 $t['line'] = 0;
             }
             if (!isset($t['function'])) {
                 $t['function'] = 'unknown';
             }
             $outputTrace .= "#{$i} {$t['file']}({$t['line']}): ";
             if (isset($t['object']) && is_object($t['object'])) {
                 $outputTrace .= get_class($t['object']) . '->';
             }
             $outputTrace .= "{$t['function']}()\n";
         }
         $errorArr = array('error' => $code . ' : ' . $message, 'trace' => $outputTrace, 'file' => $file, 'line' => $line);
     } else {
         $errorArr = array('error' => $message);
     }
     JsonHelper::sendJsonHeaders();
     echo JsonHelper::encode($errorArr);
     $this->end();
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:41,代码来源:WebApp.php

示例4: returnJson

 /**
  * Outputs JSON encoded data to standard output stream, useful during AJAX requests
  *
  * @param array $variables
  */
 public function returnJson($variables = array())
 {
     JsonHelper::sendJsonHeaders();
     // Output it into a buffer, in case TasksService wants to close the connection prematurely
     ob_start();
     echo JsonHelper::encode($variables);
     craft()->end();
 }
开发者ID:jackmcgreevy,项目名称:fast,代码行数:13,代码来源:SproutEmailService.php

示例5: actionExport

 public function actionExport()
 {
     $this->requirePostRequest();
     $fields = craft()->request->getParam('selectedFields');
     $fieldsObj = craft()->fieldManager_export->export($fields);
     // Support PHP <5.4, JSON_PRETTY_PRINT = 128, JSON_NUMERIC_CHECK = 32
     $json = json_encode($fieldsObj, 128 | 32);
     HeaderHelper::setDownload('export.json', strlen($json));
     JsonHelper::sendJsonHeaders();
     echo $json;
     craft()->end();
 }
开发者ID:imarc,项目名称:padstone,代码行数:12,代码来源:FieldManagerController.php

示例6: returnJson

 /**
  * Respond with JSON
  *
  * @param array $var The array to JSON-encode and return
  */
 public function returnJson($var)
 {
     JsonHelper::sendJsonHeaders();
     echo JsonHelper::encode($var);
     craft()->end();
 }
开发者ID:kentonquatman,项目名称:portfolio,代码行数:11,代码来源:BaseController.php


注:本文中的JsonHelper::sendJsonHeaders方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。