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