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


PHP JsonModel::setVariable方法代碼示例

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


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

示例1: folderPermissionsAction

 public function folderPermissionsAction()
 {
     $jsonModel = new JsonModel();
     foreach ($this->config['component'] as $component) {
         if (@$component['image_path'] || @$component['video_path'] || @$component['file_path']) {
             if (isset($component['image_path']) && !empty($component['image_path'])) {
                 if (!file_exists($component['image_path'])) {
                     $oldmask = umask(0);
                     mkdir($component['image_path'], 0777);
                     umask($oldmask);
                     $jsonModel->setVariable($component['image_path'], $component['image_path']);
                 }
             }
             if (isset($component['video_path']) && !empty($component['video_path'])) {
                 if (!file_exists($component['video_path'])) {
                     $oldmask = umask(0);
                     mkdir($component['video_path'], 0777);
                     umask($oldmask);
                     $jsonModel->setVariable($component['video_path'], $component['video_path']);
                 }
             }
             if (isset($component['file_path']) && !empty($component['file_path'])) {
                 if (!file_exists($component['file_path'])) {
                     $oldmask = umask(0);
                     mkdir($component['file_path'], 0777);
                     umask($oldmask);
                     $jsonModel->setVariable($component['file_path'], $component['file_path']);
                 }
             }
         }
     }
     $response = $this->getResponse();
     $response->setContent(json_encode($jsonModel->getVariables()));
     return $response;
 }
開發者ID:kalelc,項目名稱:inventory,代碼行數:35,代碼來源:ConfigController.php

示例2: indexAction

 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     $json = new JsonModel();
     $json->setVariable('nav', $this->navigation->getData());
     $json->setVariable('menu', $this->navigation->getMenuItems());
     $json->setVariable('main', $this->navigation->getMainItems());
     $json->setVariable('titles', $this->navigation->getTitles());
     return $json;
 }
開發者ID:kidaa30,項目名稱:magento2-platformsh,代碼行數:12,代碼來源:Navigation.php

示例3: startAction

 /**
  * Index Action
  *
  * @return JsonModel
  */
 public function startAction()
 {
     $this->log->clear();
     $json = new JsonModel();
     try {
         $data = array_merge($this->importDeploymentConfigForm(), $this->importUserConfigForm(), $this->importAdminUserForm());
         $this->installer->install($data);
         $json->setVariable('key', $this->installer->getInstallInfo()[SetupConfigOptionsList::KEY_ENCRYPTION_KEY]);
         $json->setVariable('success', true);
         $json->setVariable('messages', $this->installer->getInstallInfo()[Installer::INFO_MESSAGE]);
     } catch (\Exception $e) {
         $this->log->logError($e);
         $json->setVariable('success', false);
     }
     return $json;
 }
開發者ID:opexsw,項目名稱:magento2,代碼行數:21,代碼來源:Install.php

示例4: setErrors

 /**
  * @param mixed $errors
  */
 public function setErrors(array $errors)
 {
     $this->errors = $errors;
     if (empty($errors)) {
         $this->setSuccess(true);
     } else {
         $this->setSuccess(false);
     }
     parent::setVariable('errors', $errors);
     return $this;
 }
開發者ID:phox,項目名稱:xsale,代碼行數:14,代碼來源:JsonResultModel.php

示例5: 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

示例6: deleteAction

 public function deleteAction()
 {
     $jsonModel = new JsonModel();
     $id = (int) $this->params()->fromPost('id');
     if ($id > 0) {
         $result = $this->getNoteTable()->delete($id);
     } else {
         $result = false;
     }
     $jsonModel->setVariable("result", $result);
     return $jsonModel;
 }
開發者ID:kalelc,項目名稱:inventory,代碼行數:12,代碼來源:NoteController.php

示例7: deleteAction

 public function deleteAction()
 {
     $id = $this->params()->fromQuery('id');
     $em = $this->getEntityManager();
     $jsonModel = new JsonModel();
     /** @var  $res \Base\Entity\Competition */
     $res = $em->getRepository('Base\\Entity\\User')->find($id);
     $em->remove($res);
     $em->flush();
     $jsonModel->setVariable('success', true);
     return $jsonModel;
 }
開發者ID:hamichen,項目名稱:CMS,代碼行數:12,代碼來源:UserController.php

示例8: indexAction

 /**
  * @return JsonModel
  */
 public function indexAction()
 {
     $this->logger->clear();
     $data = Json::decode($this->getRequest()->getContent(), Json::TYPE_ARRAY);
     $this->config->setConfigData($data);
     $this->config->install();
     $this->setupFactory->setConfig($this->config->getConfigData());
     $moduleNames = array_keys($this->moduleList);
     foreach ($moduleNames as $moduleName) {
         $setup = $this->setupFactory->create($moduleName);
         $setup->applyUpdates();
         $this->logger->logSuccess($moduleName);
     }
     $this->logger->logSuccess('Artifact');
     // Set data to config
     $setup->addConfigData('web/seo/use_rewrites', isset($data['config']['rewrites']['allowed']) ? $data['config']['rewrites']['allowed'] : 0);
     $setup->addConfigData('web/unsecure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{unsecure_base_url}}');
     $setup->addConfigData('web/secure/use_in_frontend', isset($data['config']['https']['front']) ? $data['config']['https']['front'] : 0);
     $setup->addConfigData('web/secure/base_url', isset($data['config']['address']['web']) ? $data['config']['address']['web'] : '{{secure_base_url}}');
     $setup->addConfigData('web/secure/use_in_adminhtml', isset($data['config']['https']['admin']) ? $data['config']['https']['admin'] : 0);
     $setup->addConfigData('general/locale/code', isset($data['store']['language']) ? $data['store']['language'] : 'en_US');
     $setup->addConfigData('general/locale/timezone', isset($data['store']['timezone']) ? $data['store']['timezone'] : 'America/Los_Angeles');
     $currencyCode = isset($data['store']['currency']) ? $data['store']['currency'] : 'USD';
     $setup->addConfigData('currency/options/base', $currencyCode);
     $setup->addConfigData('currency/options/default', $currencyCode);
     $setup->addConfigData('currency/options/allow', $currencyCode);
     // Create administrator account
     $this->adminAccountFactory->setConfig($this->config->getConfigData());
     $adminAccount = $this->adminAccountFactory->create($setup);
     $adminAccount->save();
     $this->logger->logSuccess('Admin User');
     if ($data['config']['encrypt']['type'] == 'magento') {
         $key = md5($this->random->getRandomString(10));
     } else {
         $key = $data['config']['encrypt']['key'];
     }
     $this->config->replaceTmpEncryptKey($key);
     $this->config->replaceTmpInstallDate(date('r'));
     $phpPath = $this->phpExecutablePath();
     exec($phpPath . 'php -f ' . escapeshellarg($this->systemConfig->create()->getMagentoBasePath() . '/dev/shell/run_data_fixtures.php'), $output, $exitCode);
     if ($exitCode !== 0) {
         $outputMsg = implode(PHP_EOL, $output);
         $this->logger->logError(new \Exception('Data Update Failed with Exit Code: ' . $exitCode . PHP_EOL . $outputMsg));
         $this->json->setVariable('success', false);
     } else {
         $this->logger->logSuccess('Data Updates');
         $this->json->setVariable('success', true);
     }
     $this->json->setVariable('key', $key);
     return $this->json;
 }
開發者ID:buskamuza,項目名稱:magento2-skeleton,代碼行數:54,代碼來源:StartController.php

示例9: 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

示例10: validFormAction

 public function validFormAction()
 {
     $jsonModel = new JsonModel();
     $formData = $this->params()->fromPost();
     $formManager = $this->getServiceLocator()->get('formElementManager');
     $form = $formManager->get('addressForm');
     $form->setData($formData);
     $result = $form->isValid();
     $messages = [];
     if (!$result) {
         $messages = $form->getMessages();
     }
     $jsonModel->setVariable('jsonData', ['isValid' => $result, 'messages' => $messages]);
     $this->getResponse()->getHeaders()->addHeaderLine('content-type', 'application/json');
     return $jsonModel;
 }
開發者ID:adacap,項目名稱:3agest-prototype,代碼行數:16,代碼來源:AddressFormController.php

示例11: productSearchSerialAction

 public function productSearchSerialAction()
 {
     $product = $this->params()->fromPost('product');
     $jsonModel = new JsonModel();
     $productList = array();
     if (isset($product) && !empty($product)) {
         $products = $this->getProductTable()->getBySerial($product);
         foreach ($products as $key => $productValue) {
             //if(stristr($productValue,$product)){
             $productList[$key] = $productValue;
             //}
         }
         $jsonModel->setVariable("products", $productList);
         return $jsonModel;
     }
 }
開發者ID:kalelc,項目名稱:inventory,代碼行數:16,代碼來源:ProductController.php

示例12: updaterolefeatureAction

 public function updaterolefeatureAction()
 {
     $actionId = $this->getRequest()->getPost('actionId');
     $roleId = $this->getRequest()->getPost('roleId');
     $value = $this->getRequest()->getPost('value');
     $jsonModel = new JsonModel();
     if (in_array($roleId, array(\User\Model\User::ROLE_ADMIN, \User\Model\User::ROLE_SUPERADMIN, \User\Model\User::ROLE_MEMBER, \User\Model\User::ROLE_GUEST))) {
         $jsonModel->setVariables(array('code' => 0, 'messages' => ['Không thể điều chỉnh quyền này của nhóm người dùng này']));
         return $jsonModel;
     }
     $role = new \System\Model\Role();
     $role->setId($roleId);
     $roleMapper = $this->getServiceLocator()->get('\\System\\Model\\RoleMapper');
     if (!$roleMapper->get($role)) {
         $jsonModel->setVariables(array('code' => 0, 'messages' => ['Không tìm thấy quyền này']));
         return $jsonModel;
     }
     $action = new Action();
     $action->setId($actionId);
     $actionMapper = $this->getServiceLocator()->get('\\System\\Model\\ActionMapper');
     if (!$actionMapper->get($action)) {
         $jsonModel->setVariables(array('code' => 0, 'messages' => ['Không tìm thấy action này']));
         return $jsonModel;
     }
     $roleFeature = new \System\Model\Role\Feature();
     $roleFeature->setActionId($actionId);
     $roleFeature->setRoleId($roleId);
     $roleFeatureMapper = $this->getServiceLocator()->get('\\System\\Model\\Role\\FeatureMapper');
     if ($value) {
         if (!$roleFeatureMapper->isExisted($roleFeature)) {
             $roleFeature->setCreatedById($this->user()->getIdentity());
             $roleFeature->setCreatedDateTime(DateBase::getCurrentDateTime());
             $roleFeatureMapper->save($roleFeature);
         }
     } else {
         if ($roleFeatureMapper->isExisted($roleFeature)) {
             $roleFeatureMapper->delete($roleFeature);
         }
     }
     $jsonModel->setVariable('code', 1);
     return $jsonModel;
 }
開發者ID:projectHN,項目名稱:mentor,代碼行數:42,代碼來源:FeatureController.php

示例13: groupAction

 /**
  * Return group members in JSON
  *
  * @return \Zend\View\Model\ViewModel
  */
 public function groupAction()
 {
     $jsonModel = new JsonModel(array('success' => false));
     $groupId = $this->getRequest()->getPost('group');
     if (empty($groupId) || !is_numeric($groupId)) {
         return $jsonModel;
     }
     $groupMembers = $this->groupService->fetchGroupMembers($groupId, $this->identity->getId());
     $jsonModel->setVariable('success', true);
     $jsonModel->setVariable('groupMembers', $groupMembers);
     return $jsonModel;
 }
開發者ID:dotuancd,項目名稱:secretary,代碼行數:17,代碼來源:NoteController.php

示例14: deleteFileAction

 public function deleteFileAction()
 {
     $id = (int) $this->params()->fromQuery('id');
     $em = $this->getEntityManager();
     /** @var  $res \base\Entity\PageFile */
     $res = $em->getRepository('Base\\Entity\\PageFile')->find($id);
     $jsonModel = new JsonModel();
     if ($res) {
         $fileName = $res->getFileName();
         $filePath = $this->FileStorePath() . '/' . $fileName;
         if (is_file($filePath)) {
             unlink($filePath);
         }
         $em->remove($res);
         $em->flush();
         $jsonModel->setVariable('success', true);
     } else {
         $jsonModel->setVariable('success', false);
     }
     return $jsonModel;
 }
開發者ID:hamichen,項目名稱:CMS,代碼行數:21,代碼來源:PageController.php

示例15: searchUsersAction

 /**
  * Helper action for userselect form element.
  * 
  * @return \Zend\View\Model\JsonModel
  */
 public function searchUsersAction()
 {
     if (!$this->getRequest()->isXmlHttpRequest()) {
         throw new \RuntimeException('This action must be called via ajax request');
     }
     $model = new JsonModel();
     $query = $this->params()->fromPost('query', false);
     if (false === $query) {
         $result = array();
     } else {
         $services = $this->getServiceLocator();
         $repositories = $services->get('repositories');
         $repository = $repositories->get('Auth/User');
         $users = $repository->findByQuery($query);
         $userFilter = $services->get('filtermanager')->get('Auth/Entity/UserToSearchResult');
         $filterFunc = function ($user) use($userFilter) {
             return $userFilter->filter($user);
         };
         $result = array_values(array_map($filterFunc, $users->toArray()));
     }
     $model->setVariable('users', $result);
     return $model;
 }
開發者ID:bitrecruiter,項目名稱:CrossApplicantManager,代碼行數:28,代碼來源:ManageGroupsController.php


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