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


PHP JsonModel::setJsonpCallback方法代碼示例

本文整理匯總了PHP中Zend\View\Model\JsonModel::setJsonpCallback方法的典型用法代碼示例。如果您正苦於以下問題:PHP JsonModel::setJsonpCallback方法的具體用法?PHP JsonModel::setJsonpCallback怎麽用?PHP JsonModel::setJsonpCallback使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Zend\View\Model\JsonModel的用法示例。


在下文中一共展示了JsonModel::setJsonpCallback方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: testCanSerializeWithJsonpCallback

 public function testCanSerializeWithJsonpCallback()
 {
     $array = array('foo' => 'bar');
     $model = new JsonModel($array);
     $model->setJsonpCallback('callback');
     $this->assertEquals('callback(' . Json::encode($array) . ');', $model->serialize());
 }
開發者ID:benivaldo,項目名稱:zf2-na-pratica,代碼行數:7,代碼來源:JsonModelTest.php

示例2: getJson

 public static function getJson($data, $callback = null)
 {
     $json = new JsonModel($data);
     if ($callback != null) {
         $json->setJsonpCallback($callback);
     }
     return $json;
 }
開發者ID:rodrigogk87,項目名稱:djme,代碼行數:8,代碼來源:ResponseUtils.php

示例3: indexAction

 public function indexAction()
 {
     $organizationId = $this->params()->fromRoute('organizationId', 0);
     try {
         $jobs = $this->jobRepository->findByOrganization($organizationId);
     } catch (\Exception $e) {
         /** @var Response $response */
         $response = $this->getResponse();
         $response->setStatusCode(Response::STATUS_CODE_404);
         return $response;
     }
     $jsonModel = new JsonModel();
     $jsonModel->setVariables($this->apiJobDehydrator->dehydrateList($jobs));
     $jsonModel->setJsonpCallback('yawikParseJobs');
     return $jsonModel;
 }
開發者ID:utrenkner,項目名稱:YAWIK,代碼行數:16,代碼來源:ApiJobListByOrganizationController.php

示例4: jsAction

 /**
  * Apresentar Configurações
  *
  * @return JsonModel Modelo de Visualização
  */
 public function jsAction()
 {
     // Capturar Configurações
     $configs = [];
     // Inicialização
     $view = new JsonModel($configs);
     // Requisição
     $request = $this->getRequest();
     // Tipagem Correta?
     if (!$request instanceof Http\PhpEnvironment\Request) {
         throw new Exception('Invalid Request');
     }
     // Configurar Caminho Base
     $view->setVariable('basePath', $this->getRequest()->getBaseUrl());
     // Configurar Linguagem de Localização
     $view->setVariable('locale', $this->getLocale());
     // Configurar Variável
     $view->setJsonpCallback('$.application.setConfigs');
     // Apresentação
     return $view;
 }
開發者ID:wandersonwhcr,項目名稱:balance,代碼行數:26,代碼來源:Configs.php

示例5: translateAction

 /**
  * Translate
  *
  * @return JsonModel
  */
 public function translateAction()
 {
     $model = new JsonModel();
     $namespace = $this->getEvent()->getRouteMatch()->getParam('namespace', 'default');
     $locale = $this->getEvent()->getRouteMatch()->getParam('locale', null);
     if ($this->getRequest()->getMethod() === 'GET') {
         $params = $this->getRequest()->getQuery();
         if (array_key_exists('callback', $params)) {
             $model->setJsonpCallback($params['callback']);
         }
     } else {
         $params = $this->getRequest()->getPost();
     }
     if (!isset($params['key'])) {
         $model->setVariable('error', 'No key[] given');
     }
     if (!is_array($params['key'])) {
         $params['key'] = array($params['key']);
     }
     foreach ($params['key'] as $key) {
         $model->setVariable($key, $this->getTranslator()->translate($key, $namespace, $locale));
     }
     return $model;
 }
開發者ID:jdolieslager,項目名稱:fetranslator,代碼行數:29,代碼來源:Translate.php

示例6: msg

 /**
  * 返回信息
  *
  * @param bool $status            
  * @param string $message            
  * @param string $jsonModel            
  * @return \Zend\View\Model\JsonModel multitype:unknown <boolean, unknown>
  */
 public function msg($status, $message, $jsonModel = true, $jsonpCallback = null)
 {
     $rst = array('success' => is_bool($status) ? $status : false, 'msg' => $message);
     if ($jsonModel) {
         $obj = new JsonModel($rst);
         if ($jsonpCallback !== null) {
             $obj->setJsonpCallback($jsonpCallback);
         }
         return $obj;
     }
     return $rst;
 }
開發者ID:im286er,項目名稱:ent,代碼行數:20,代碼來源:Action.php


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