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


PHP JsonResponse类代码示例

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


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

示例1: json

 /**
  * @param array $data
  * @param int $statusCode
  * @return Response
  */
 public static function json(array $data, $statusCode = 200)
 {
     $response = new JsonResponse();
     $response->setContent(json_encode($data, JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_AMP | JSON_HEX_QUOT));
     $response->setHeader('Content-Type', 'application/json');
     $response->setStatusCode($statusCode);
     return $response;
 }
开发者ID:ivan-kolesov,项目名称:test-example,代码行数:13,代码来源:Response.php

示例2: areas

 public function areas()
 {
     $areas = $this->dao->getAreas();
     if ($areas->count() > 0) {
         return $this->returnJson($areas);
     }
     $json = new JsonResponse();
     return $json->response(false, "Nenhuma área encontrada!")->serialize();
 }
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:9,代码来源:Controller.php

示例3: getMenusAction

 /**
  * Get memus - Makes search bar work.
  */
 public function getMenusAction()
 {
     $menusData = array();
     $systemTableService = $this->get('SystemTableService');
     $menus = $systemTableService->getMenus();
     foreach ($menus as $menu) {
         $menusData[] = array('id' => $menu->getId(), 'name' => $menu->getName());
     }
     $response = new JsonResponse();
     $response->setData($menusData);
     return $response;
 }
开发者ID:pavsuri,项目名称:PARMT,代码行数:15,代码来源:DefaultController.php

示例4: updateCostosAction

 public function updateCostosAction($id, $hash)
 {
     $today = new \DateTime();
     if ($hash != md5($today->format('Y-m-d'))) {
         $logger = $this->get('logger');
         $logger->error('Access denied on updateCostosAction');
         $returnJson = new JsonResponse();
         $returnJson->setData(array('ok' => true));
         return $returnJson;
     }
     $migrationService = $this->get('kinder.migrations');
     $migrationService->updateCostos();
     $returnJson = new JsonResponse();
     $returnJson->setData(array('ok' => true));
     return $returnJson;
 }
开发者ID:rsantellan,项目名称:bunnies-kinder2,代码行数:16,代码来源:MigrationCodiguerasController.php

示例5: datesIncluded

 public static function datesIncluded()
 {
     if (!isset($_REQUEST[START_DATE], $_REQUEST[END_DATE])) {
         echo JsonResponse::error("Incomplete request parameters!");
         exit;
     }
 }
开发者ID:ademolaoduguwa,项目名称:pms,代码行数:7,代码来源:ReportController.php

示例6: parseException

 protected function parseException()
 {
     /** @var APIResponse $response */
     $response = app(APIResponse::class);
     $fe = FlattenException::create($e);
     $data = env("APP_DEBUG", false) ? $fe->toArray() : ["message" => "whoops, something wrong."];
     return JsonResponse::create($data, 500);
 }
开发者ID:chatbox-inc,项目名称:lumen-app,代码行数:8,代码来源:Handler.php

示例7: run

 public function run(Request $request)
 {
     $queueRepository = \Contao\Doctrine\ORM\EntityHelper::getRepository('Avisota\\Contao:Queue');
     $queueId = $request->get('id');
     $queue = $queueRepository->find($queueId);
     /** @var \Avisota\Contao\Entity\Queue $queue */
     if (!$queue) {
         header("HTTP/1.0 404 Not Found");
         echo '<h1>404 Not Found</h1>';
         exit;
     }
     $user = \BackendUser::getInstance();
     $user->authenticate();
     try {
         return $this->execute($request, $queue, $user);
     } catch (\Exception $exception) {
         $response = new JsonResponse(array('error' => sprintf('%s in %s:%d', $exception->getMessage(), $exception->getFile(), $exception->getLine())), 500);
         $response->prepare($request);
         return $response;
     }
 }
开发者ID:Ainschy,项目名称:contao-core,代码行数:21,代码来源:AbstractQueueWebRunner.php

示例8: recv

 public function recv()
 {
     $rawResponse = '';
     do {
         $bytesRead = $this->clientSocket->read($buffer, 1024);
         if ($bytesRead > 0) {
             $rawResponse .= $buffer;
         } else {
             break;
         }
     } while ($rawResponse[strlen($rawResponse) - 1] != '\\n');
     if ($rawResponse) {
         return JsonResponse::parse($rawResponse);
     }
     return null;
 }
开发者ID:Athorcis,项目名称:athorrent-frontend,代码行数:16,代码来源:JsonClient.php

示例9: JsonResponse

<?php

$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$TITLE, 'subarea', 'year', 'publication_type')) {
    if (RequestsPatterns::postParamsSent(RequestsPatterns::$TITLE, 'subarea', 'year', 'publication_type')) {
        require_once 'File.php';
        require_once 'PublicationController.php';
        require_once 'Publication.php';
        require_once 'Paper.php';
        require_once 'PublicationDao.php';
        require_once '../core/generics/SubArea.php';
        //require_once '../core/generics/State.php';
        require_once '../core/generics/PublicationType.php';
        //$jsonResponse = new JsonResponse();
        $file = $_FILES['Arquivo'];
        $controller = new PublicationController(new PublicationDao(Connection::connect()));
        $controller->setPath("../publicacao/");
        $publicationType = new PublicationType(null, $_POST['publication_type']);
        $publication = new Paper($_POST['title'], new SubArea(null, $_POST['subarea']), new File($file), null, date("Y-m-d"), null, $publicationType, $_POST['year']);
        //print_r($jsonResponse->response(false, $publication->getTypeId())->withoutHeader()->serialize());
        try {
            $controller->savePaper($publication);
            print_r($jsonResponse->response(true, "Arquivo enviado com sucesso!")->withoutHeader()->serialize());
        } catch (Exception $err) {
            print_r($jsonResponse->response(false, $err->getMessage())->withoutHeader()->serialize());
        }
    } else {
        print_r($jsonResponse->response(false, "Todos os campos devem ser preenchidos e/ou marcados.")->withoutHeader()->serialize());
    }
} else {
    print_r($jsonResponse->response(false, "Parâmetros não configurados corretamente.")->withoutHeader()->serialize());
开发者ID:raigons,项目名称:bureauinteligencia,代码行数:31,代码来源:save-paper.php

示例10: Copyright

<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2015 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
//$ses=Session::getInstance();
$toReturn = new JsonResponse();
if (isset($_POST['email']) && trim($_POST['email']) != '') {
    // send email to support
    $info['product'] = $_POST['product'];
    $info['version'] = $_POST['version'];
    $info['username'] = $_POST['userName'];
    $info['email'] = $_POST['email'];
    $user = new User($dbConnectionInfo);
    $generateInfo = $user->generatePasswd($info);
    $productTranslate = defined("__PRODUCT_NAME__") ? __PRODUCT_NAME__ : $info['product'];
    if ($generateInfo['generated'] == "") {
        // nu are email valid
        $toReturn->set("success", "false");
        $toReturn->set("message", Utils::translate('noEmailFound'));
        //echo "No ";
    } else {
        if ($generateInfo['match']) {
            // generated password
            $template = new Template("./templates/" . __LANGUAGE__ . "/recover.html");
            $confirmationMsg = $template->replace(array("username" => $info['username'], "password" => $generateInfo['generated'], "productName" => $productTranslate));
开发者ID:bdensmore,项目名称:dita-docs,代码行数:31,代码来源:recover.php

示例11: Copyright

<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once "init.php";
$cfgFile = './config/config.php';
$cfgInstall = '../../install/';
$toReturn = new JsonResponse();
if (file_exists($cfgInstall)) {
    $toReturn->set("installPresent", "true");
} else {
    $toReturn->set("installPresent", "false");
}
if (file_exists($cfgFile) && filesize($cfgFile) > 0) {
    $toReturn->set("configPresent", "true");
} else {
    $toReturn->set("configPresent", "false");
}
echo $toReturn;
开发者ID:phoenix-mossimo,项目名称:BTS-Manual,代码行数:24,代码来源:checkInstall.php

示例12: elseif

        $toReturn->set("name", $ses->{$fullUser}->name);
        $toReturn->set("userName", $ses->{$fullUser}->userName);
        $toReturn->set("level", $ses->{$fullUser}->level);
    } else {
        if (strlen(trim($user->msg)) > 0) {
            $toReturn->set("error", $user->msg);
        }
    }
    echo $toReturn;
} elseif (isset($_POST['logOff']) && trim($_POST['logOff']) != '') {
    $ses->errBag = null;
    unset($ses->errBag);
    unset($ses->{$fullUser});
    // 		echo print_r($_POST,true);
} elseif (isset($_POST['check']) && trim($_POST['check']) != '') {
    $toReturn = new JsonResponse();
    $toReturn->set("isAnonymous", "false");
    $toReturn->set("loggedIn", "false");
    if (defined('__GUEST_POST__') && !__GUEST_POST__ && (isset($ses->{$fullUser}) && $ses->{$fullUser}->isAnonymous == 'true')) {
        unset($ses->{$fullUser});
    }
    if (defined('__GUEST_POST__') && __GUEST_POST__ && !isset($ses->{$fullUser})) {
        $user = new User($dbConnectionInfo);
        // user not logged in and guest is allowed to post
        if (!$user->initAnonymous()) {
            $toReturn->set("isAnonymous", "false");
            $toReturn->set("loggedIn", "false");
            $toReturn->set("msg", "1");
            $toReturn->set("msgType", "error");
        } else {
            // anonymous must be logged in
开发者ID:aidanreilly,项目名称:documentation,代码行数:31,代码来源:checkUser.php

示例13: Copyright

<?php

/*
    
Oxygen Webhelp plugin
Copyright (c) 1998-2014 Syncro Soft SRL, Romania.  All rights reserved.
Licensed under the terms stated in the license file EULA_Webhelp.txt 
available in the base directory of this Oxygen Webhelp plugin.
*/
require_once 'init.php';
$toReturn = new JsonResponse();
if (isset($_POST['id']) && trim($_POST['id']) != '') {
    $realId = base64_decode($_POST['id']);
    //list($id,$date,$action,$newPassword) = explode("|", $realId);
    $args = explode("|", $realId);
    $id = $args[0];
    $date = $args[1];
    $action = "new";
    $newPassword = "";
    if (count($args) > 2) {
        $action = $args[2];
        $newPassword = $args[3];
    }
    $user = new User($dbConnectionInfo);
    //echo "id=".$id." date=".$date;
    $currentDate = date("Y-m-d G:i:s");
    $days = Utils::getTimeDifference($currentDate, $date, 3);
    if ($days > 7) {
        $toReturn->set("error", true);
        $toReturn->set("msg", "Confirmation code expired!");
    } else {
开发者ID:phoenix-mossimo,项目名称:BTS-Manual,代码行数:31,代码来源:confirmUser.php

示例14: toJson

 /**
  * Helper method to return a JSON response.
  *
  * @param mixed $data
  *  The data to return as the response.
  * @param int $status
  *  The HTTP status code for this response.
  *
  * @return JsonResponse
  *
  */
 public function toJson($data, $status = 200)
 {
     return JsonResponse::create($data, $status);
 }
开发者ID:krisolafson,项目名称:restapi,代码行数:15,代码来源:HttpResponseFactory.php

示例15: array

 function __Construct($dictionary)
 {
     parent::__Construct(get_class());
     $categories = array();
     $list = ServiceCategory::GetAll(array('partnerCode' => Application::PARTNER_CODE, 'parentId' => null), null, $dictionary->getCode());
     foreach ($list as $category) {
         $categories[] = $category->toArray(true);
     }
     $this->jsonData = array('categories' => $categories);
 }
开发者ID:TreatNOW,项目名称:TNfrontend,代码行数:10,代码来源:CategoriesResponse.inc.php


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