本文整理汇总了PHP中Zend\View\Model\JsonModel::setTerminal方法的典型用法代码示例。如果您正苦于以下问题:PHP JsonModel::setTerminal方法的具体用法?PHP JsonModel::setTerminal怎么用?PHP JsonModel::setTerminal使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\View\Model\JsonModel
的用法示例。
在下文中一共展示了JsonModel::setTerminal方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getThumbsAction
public function getThumbsAction()
{
// width of html doc
$screen_width = (int) $this->params()->fromQuery('screen_width');
//width of browser viewport
$width = (int) $this->params()->fromQuery('width');
$height = (int) $this->params()->fromQuery('height');
$direction = $this->params()->fromQuery('direction');
$galleryModel = $this->getVideosModel();
$limit = $galleryModel->getLimit($width, $height);
//$page = (int)$this->params('page');
$page = (int) $this->params()->fromQuery('page');
$offset = 0;
if ($page > 0) {
$offset = $page * $limit;
}
$cache = $this->getVideosModel()->getThumbVideosCache();
$key = $offset . "_" . $limit;
$jsonStr = $cache->getItem($key, $success);
if ($this->disableCache || !$success) {
$thumbArr = $this->getVideosMapper()->fetchThumbArr($offset, $limit);
if ($thumbArr) {
$cache->setItem($key, serialize($thumbArr));
}
} else {
$thumbArr = unserialize($jsonStr);
}
$jsonModel = new JsonModel(array("result" => $thumbArr));
$jsonModel->setTerminal(true);
return $jsonModel;
}
示例2: handleRequest
/**
* Call this method from the appropriate action method
*
* @return ApiProblemResponse|JsonModel
*/
public function handleRequest()
{
$request = $this->getRequest();
if ($request->getMethod() != $request::METHOD_GET) {
return new ApiProblemResponse(new ApiProblem(405, 'Only the GET method is allowed for this URI'));
}
$model = new JsonModel([$this->property => $this->model->fetchAll()]);
$model->setTerminal(true);
return $model;
}
示例3: getJsonResponse
/**
* getJsonResponse
*
* @param Result $result result
*
* @return \Zend\Stdlib\ResponseInterface
*/
public function getJsonResponse($result)
{
$view = new JsonModel();
$view->setTerminal(true);
$response = $this->getResponse();
$json = json_encode($result);
$response->setContent($json);
$response->getHeaders()->addHeaders(['Content-Type' => 'application/json']);
return $response;
}
示例4: build
/**
* @param HttpRequest $request
*
* @return \Zend\View\Model\ViewModel
*/
public function build(HttpRequest $request, SmartServiceResult $result, $action)
{
$viewModel = null;
if ($request->isXmlHttpRequest()) {
$viewModel = new JsonModel();
$viewModel->setTerminal(true);
} else {
$viewModel = new \Zend\View\Model\ViewModel();
$viewModel->setVariable('entity', $result->getEntity());
$viewModel->setVariable('form', $result->getForm());
$viewModel->setVariable('list', $result->getList());
$viewModel->setTemplate(sprintf($this->getTemplate(), $action));
}
return $viewModel;
}
示例5: onRender
/**
* Method executed when the render event is triggered
*
* @param MvcEvent $e
* @return void
*/
public static function onRender(MvcEvent $e)
{
if ($e->getRequest() instanceof \Zend\Console\Request || $e->getResponse()->isOk() || $e->getResponse()->getStatusCode() == Response::STATUS_CODE_401) {
return;
}
$httpCode = $e->getResponse()->getStatusCode();
$sm = $e->getApplication()->getServiceManager();
$viewModel = $e->getResult();
$exception = $viewModel->getVariable('exception');
$model = new JsonModel(array('errorCode' => !empty($exception) ? $exception->getCode() : $httpCode, 'errorMsg' => !empty($exception) ? $exception->getMessage() : NULL));
$model->setTerminal(true);
$e->setResult($model);
$e->setViewModel($model);
$e->getResponse()->setStatusCode($httpCode);
}
示例6: getCamGirlsOnlineAction
public function getCamGirlsOnlineAction()
{
$cache = $this->getCache();
$key = $this->getCacheKey();
$str = $cache->getItem($key, $success);
if (!$success) {
$res = $this->getCamTable()->getCamGirlsOnline();
$res = $this->getCamModel()->buildCamgirlArr($res);
if ($res) {
$cache->setItem($key, serialize($res));
}
} else {
$res = unserialize($str);
}
$jsonModel = new JsonModel(array("result" => $res));
$jsonModel->setTerminal(true);
return $jsonModel;
}
示例7: notificarAction
public function notificarAction()
{
//Conectamos a BBDD
$sid = new Container('base');
$db_name = $sid->offsetGet('dbNombre');
$remitente = "Comit�";
$this->dbAdapter = $this->getServiceLocator()->get($db_name);
//Obtenemos datos POST
$post = $this->request->getPost();
if (isset($post['destino'])) {
//Validamos si es mensaje directo a Dpto
if (isset($post['dpto'])) {
//Consultamos datos del dpto
$dptoMail = new UnidadTable($this->dbAdapter);
$lista = $dptoMail->getVerResidentesActivos($this->dbAdapter, $post['id_unidad']);
$htmlMarkup = \HtmlCorreo::htmlMensajeDirecto($lista[0]['nombre'], $remitente, $post['textbody']);
$html = new MimePart($htmlMarkup);
$html->type = "text/html";
$body = new MimeMessage();
$body->setParts(array($html));
$message = new Message();
$message->addTo($lista[0]['correo'])->addFrom('notificacion@becheck.cl', 'Notificacion becheck')->setSubject($post['asunto'])->setBody($body);
$transport = new SendmailTransport();
$transport->send($message);
//Retornamos a la vista
$result = new JsonModel(array('status' => 'ok', 'descripcion' => 'Se ha enviado correctamente un correo'));
//$result->setTerminal(true);
return $result;
}
$result = new JsonModel(array('status' => 'ok', 'descripcion' => $post));
$result->setTerminal(true);
return $result;
}
//Instancias
$dpto = new UnidadTable($this->dbAdapter);
$form = new NotificacionForm("form");
//Obtenemos combo dptos
$dptos = $dpto->getDatosActivos();
//Cargamos dptos en formulario
$form->get('id_unidad')->setAttribute('options', $dptos);
$this->layout('layout/comite');
return new ViewModel(array('form' => $form));
}
示例8: handleError
public function handleError(MvcEvent $e)
{
if ($e->getError() == Application::ERROR_ROUTER_NO_MATCH) {
return;
}
if ($e->getError() == Application::ERROR_EXCEPTION) {
$translator = $e->getApplication()->getServiceManager()->get('translator');
$exception = $e->getParam('exception');
if ($exception instanceof BusinessException) {
// translate
$status = intval($exception->getCode());
$messsage = $translator->translate($exception->getMessage());
} else {
$status = 999;
if (isset($_SERVER['APPLICATION_ENV']) && $_SERVER['APPLICATION_ENV'] == 'development') {
$messsage = $exception->getMessage();
} else {
$messsage = '对不起, 系统出错了...';
}
}
/* @var $request \Zend\Http\Request */
$request = $e->getRequest();
$response = $e->getResponse();
if ($request->isXmlHttpRequest()) {
// change status code from 500 to 200
$response->setStatusCode(200);
$response->getHeaders()->addHeaders(array('Content-type' => 'application/json; charset=utf8'));
$json = new JsonModel();
$json->setVariables(array('status' => $status, 'message' => $messsage, 'content' => array()));
$json->setTerminal(false);
$e->setViewModel($json);
// mute other default exception handler
$e->setError(false);
}
}
}
示例9: getJsonResponse
/**
* getJsonResponse
*
* @param $data $data
*
* @return \Zend\Stdlib\ResponseInterface
*/
public function getJsonResponse($data)
{
$view = new JsonModel();
$view->setTerminal(true);
$response = $this->getResponse();
$response->setContent(json_encode($data));
return $response;
}
示例10: onRenderError
/**
* Render JSON response on Error
*
* @param MvcEvent $e
*/
public function onRenderError(MvcEvent $e)
{
// must be an error
if (!$e->isError()) {
return;
}
// if we have a JsonModel in the result, then do nothing
$currentModel = $e->getResult();
if ($currentModel instanceof JsonModel) {
return;
}
// create a new JsonModel - use application/api-problem+json fields.
/**
*
* @var Response $response
*/
$response = $e->getResponse();
/** @var \Exception $exception */
$exception = $e->getParam('exception');
// Create a new ViewModel
$model = new JsonModel(array("httpStatus" => $exception ? $exception->getCode() : ($response instanceof Response ? $response->getStatusCode() : 500), "title" => $e->getError()));
if ($exception && $exception instanceof ValidationException) {
$model->httpStatus = $exception->getCode();
if ($response instanceof Response) {
$response->setStatusCode($model->httpStatus);
}
$model->title = 'validation-exception';
//We can have many validation errors
$model->validationMessages = $exception instanceof ValidationException ? $exception->getMessages() : $exception->getMessage();
}
// Add a detailed info about the error, if it exists
if (isset($_SERVER['APPLICATION_ENV']) && $_SERVER['APPLICATION_ENV'] === 'development' && $e->getError()) {
switch ($e->getError()) {
case 'error-controller-cannot-dispatch':
$model->detail = 'The requested controller was unable to dispatch the request.';
break;
case 'error-controller-not-found':
$model->detail = 'The requested controller could not be mapped to an existing controller class.';
break;
case 'error-controller-invalid':
$model->detail = 'The requested controller was not dispatchable.';
break;
case 'error-router-no-match':
$model->detail = 'The requested URL could not be matched by routing.';
break;
default:
$model->title = get_class($exception);
$model->detail = ['message' => $exception instanceof ValidationException ? $exception->getMessages() : $exception->getMessage(), 'file' => $exception->getFile(), 'line' => $exception->getLine()];
break;
}
}
// set our new view model
$model->setTerminal(true);
$e->setResult($model);
$e->setViewModel($model);
}
示例11: dataAction
public function dataAction()
{
/*
$newusername = file_get_contents('php://input'); //Получаем JSON запрос от extjs.jsonstore
$newusername = json_decode($newusername);
if(isset($newusername->user_name) && !empty($newusername->user_name)){}
*/
if (isset($_GET['act'])) {
$action = $_GET['act'];
$user = new User();
$user->user_id = $_GET['user_id'];
$user->user_name = $_GET['user_name'];
$user->user_educ = $_GET['user_educ'];
$user->city_name = $_GET['city_name'];
$city = new City();
$city->user_id = $_GET['user_id'];
$city->city_name = $_GET['city_name'];
$education = new Education();
$education->user_id = $_GET['user_id'];
$education->user_educ = $_GET['user_educ'];
switch ($action) {
case "update":
$user->user_id = $this->getUserTable()->saveUser($user);
$this->getCityTable()->saveCity($city, $user->user_id);
$this->getEducationTable()->saveEducation($education, $user->user_id);
header('Location:http://univer/user');
exit;
break;
case "delete":
$this->getUserTable()->deleteUser($user->user_id);
$this->getCityTable()->deleteCity($user->user_id);
$this->getEducationTable()->deleteEducation($user->user_id);
header('Location:http://univer/user');
exit;
break;
}
} else {
//$jsonfile = array(array("user_id"=> "1","user_name"=>"ОШИБКА!"),);
}
//-----------------------------------------------------------------------------------
//---------------Передача данных клиенту---------------------------------------------
//-----------------------------------------------------------------------------------
$user_data = array('user' => $this->getUserTable()->fetchUserInfo());
//-----------переработать!!!!!------------------------
$jsonfile = "[";
foreach ($user_data['user'] as $user) {
$jsonfile = $jsonfile . '{"user_id": "' . $user->user_id . '",
"user_name":"' . $user->user_name . '",
"user_educ":"' . $user->user_educ . '",
"city_name":"' . $user->city_name . '"},';
}
$jsonfile = substr($jsonfile, 0, -1);
//удалаем последний символ(запятую)
$jsonfile = $jsonfile . ']';
$jsonfile = json_decode($jsonfile);
//------------------------------------------------
$result = new JsonModel($jsonfile);
//$view->setTemplate('user/index/data'); //установка шаблона
$result->setTerminal(true);
//don't load layout
return $result;
}
示例12: returnJson
/**
* Return json model
*
* @param array $data Data
*
* @return \Zend\View\Model\JsonModel
*/
public function returnJson(array $data)
{
$jsonModel = new JsonModel();
$jsonModel->setVariables($data);
$jsonModel->setTerminal(true);
return $jsonModel;
}
示例13: nomegustareclamoAction
public function nomegustareclamoAction()
{
//Obtenemos datos post
$id = $this->params()->fromRoute("id", null);
//$data = $this->request->getPost();
//Conectamos con BBDD
$sid = new Container('base');
$db_name = $sid->offsetGet('dbNombre');
$this->dbAdapter = $this->getServiceLocator()->get($db_name);
$id_usuario = $sid->id_usuario;
//Instancias
$recl = new ReclamoTable($this->dbAdapter);
$recl->nomegustaReclamo($this->dbAdapter, $id, $id_usuario);
//Retornamos a la vista
$result = new JsonModel(array('status' => 'ok', 'desc' => 'Camnpo N°' . $id . ' fue actualizado'));
$result->setTerminal(true);
return $result;
}
示例14: myJsonModel
protected function myJsonModel($obj)
{
$view = new JsonModel($obj);
$view->setTerminal(true);
return $view;
}
示例15: getMonthlyNavAction
public function getMonthlyNavAction()
{
$arr = $this->getMonthlyNav();
$jsonModel = new JsonModel(array("result" => $arr));
$jsonModel->setTerminal(true);
return $jsonModel;
}