本文整理汇总了PHP中JsonResponse::response方法的典型用法代码示例。如果您正苦于以下问题:PHP JsonResponse::response方法的具体用法?PHP JsonResponse::response怎么用?PHP JsonResponse::response使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JsonResponse
的用法示例。
在下文中一共展示了JsonResponse::response方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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();
}
示例2: JsonResponse
<?php
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$TITLE, RequestsPatterns::$LINK)) {
if (RequestsPatterns::postParamsSent(RequestsPatterns::$TITLE, RequestsPatterns::$LINK)) {
require_once 'NewsController.php';
require_once 'NewsDao.php';
require_once 'NewRSS.php';
try {
$controller = new NewsController(new NewsDao(Connection::connect()));
$controller->save(new NewRSS($_POST[RequestsPatterns::$TITLE], $_POST[RequestsPatterns::$LINK]));
print_r($jsonResponse->response(TRUE, "RSS inserido com sucesso!")->serialize());
} catch (PDOException $err) {
print_r($jsonResponse->response(FALSE, $err->getMessage())->serialize());
} catch (LoginException $err) {
print_r($jsonResponse->response(NULL, $err->getMessage())->serialize());
}
} else {
print_r($jsonResponse->response(NULL, "Todos os campos devem ser preenchidos.")->serialize());
}
} else {
print_r($jsonResponse->response(FALSE, "Os parâmetros não foram configurados. Comunique o desenvolvedor")->serialize());
}
示例3: JsonResponse
<?php
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$ID)) {
if (RequestsPatterns::postParamsSent(RequestsPatterns::$ID)) {
require_once 'VideoController.php';
require_once 'VideoDao.php';
$controller = new VideoController(new VideoDao(Connection::connect()));
try {
if ($controller->delete($_POST[RequestsPatterns::$ID])) {
print_r($jsonResponse->response(true, "Video excluído com sucesso")->serialize());
} else {
print_r($jsonResponse->response(false, "Falha ao excluir o video")->serialize());
}
} catch (Exception $err) {
print_r($jsonResponse->response(false, $err->getMessage())->serialize());
}
} else {
print_r($jsonResponse->response(false, "O identificador do video não pode estar vazio!")->serialize());
}
} else {
print_r($jsonResponse->response(false, "Parâmetros não configurados!")->serialize());
}
示例4: JsonResponse
<tr>
<th>Título</th>
<th>link</th>
<th>Tema</th>
<th>Estado</th>
<?if(LinkController::link() != "analysis"):?>
<th>Tipo do Evento</th>
<?else:?>
<th>Data</th>
<?endif?>
</tr>
</thead>
<tbody>
</tbody>
</table>
</div>
</div>
</div>
</div>
</body>
</html>
<?}else{
try{
$_REQUEST['no-must-online'] = true;
include LinkController::rest();
}catch(Exception $err){
$json = new JsonResponse();
print_r($json->response(false, $err->getMessage())->serialize());
}
}
?>
示例5: JsonResponse
<?php
require_once 'util/RequestsPatterns.php';
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted('link', 'to', 'name_to') && RequestsPatterns::postParamsSent('link', 'to', 'name_to')) {
require_once 'core/email/EmailController.php';
require_once 'PublicationController.php';
require_once 'PublicationDao.php';
require_once 'Publication.php';
require_once 'Analyse.php';
require_once 'core/email/Content.php';
require_once 'core/email/Email.php';
$emailController = new EmailController();
$analysisController = new PublicationController(new PublicationDao(Connection::connect()));
$analysis = $analysisController->getAnAnalysis($_POST['link'], true);
if ($emailController->setAnalysisEmail($analysis, $_POST['to'], $_POST['name_to'])) {
print_r($jsonResponse->response(true, "Email enviado com sucesso")->serialize());
} else {
print_r($jsonResponse->response(false, "Não foi possível enviar o email")->serialize());
}
} else {
print_r($jsonResponse->response(false, "Alguns campos não foram enviados.")->serialize());
}
示例6: JsonResponse
$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());
}
示例7: insertingValuesForInternationalTrade
//$countryMap);
$statistic = new Statistic();
$grouper = new DataGrouper();
$controller = new DatacenterController($service, $statistic, $jsonResponse, $grouper, $factory);
$reader = new Spreadsheet_Excel_Reader($_FILES['Planilha']['tmp_name']);
try {
$inputFile = new ExcelInputFile($reader);
if (insertingValuesForInternationalTrade($subgroup)) {
//$typeCountry = 'origin';
$response = $controller->saveValues($inputFile, $subgroup, $font, $origin, $destiny, $coffeType, $variety, $typeCountry, true);
} else {
$response = $controller->saveValues($inputFile, $subgroup, $font, $origin, $destiny, $coffeType, $variety, $typeCountry);
}
print_r($response);
} catch (WrongFormatException $exception) {
print_r($jsonResponse->response(false, $exception->getMessage())->withoutHeader()->serialize());
} catch (Exception $exception) {
print_r($jsonResponse->response(false, $exception->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());
}
?>
<?
function insertingValuesForInternationalTrade($subgroup){
$subgroups = array(1,2,3,4,5,6);
return (in_array($subgroup, $subgroups));
}
示例8: Activity
$activity = new Activity();
$activity->setId($_POST['activity']);
$user = new User($_POST['name'], $_POST['username'], $_POST['password']);
$user->setEmail($_POST['email']);
$user->setCity($city);
$user->setActivity($activity);
$positions = 'noticias,metereologia|publicacoes,videoteca|cotacoes';
$user->setPositions($positions);
$userController = new UserController(new UserDao(Connection::connect()));
try {
if ($userController->subscribe($user, $_POST['confirm_password'])) {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(true, 'Usuário cadastrado com sucesso. Você será automaticamente conectado ao sistema')->addValue("redirectTo", LinkController::getBaseURL())->serialize());
Session::login($user);
//header('Location: '.LinkController::getBaseURL());
} else {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(false, 'Falha no cadastro do usuário. Favor tentar novamente')->serialize());
}
} catch (Exception $err) {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(false, $err->getMessage())->serialize());
}
} else {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(false, 'Parâmetros não podem estar vazios')->serialize());
}
} else {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(false, 'Parâmetros não configurados. Comunique o desenvovledor.')->serialize());
}
示例9: UserController
<?php
require_once 'util/RequestsPatterns.php';
if (RequestsPatterns::postParamsSetted('username', 'email')) {
if (RequestsPatterns::postParamsSent('username', 'email')) {
require_once 'UserController.php';
require_once 'UserDao.php';
require_once 'core/email/Content.php';
require_once 'core/email/Email.php';
require_once 'core/email/EmailController.php';
$userController = new UserController(new UserDao(Connection::connect()));
$jsonResponse = new JsonResponse();
try {
$user = new User(null, $_POST['username']);
$user->setEmail($_POST['email']);
if ($userController->newPassword($user)) {
print_r($jsonResponse->response(true, "Um email foi enviado para você com sua nova senha!")->serialize());
} else {
print_r($jsonResponse->response(true, "Falha ao gerar nova senha!")->serialize());
}
} catch (Exception $err) {
print_r($jsonResponse->response(false, $err->getMessage())->serialize());
}
} else {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(false, "Os campos não podem estar vazios")->serialize());
}
} else {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(false, "Parâmetros não configurados")->serialize());
}
示例10: VideoController
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$LINK, RequestsPatterns::$TITLE, 'subarea', 'duration', 'type_event')) {
if (RequestsPatterns::postParamsSent(RequestsPatterns::$LINK, RequestsPatterns::$TITLE, 'subarea', 'duration', 'type_event')) {
require_once "VideoController.php";
require_once "VideoDao.php";
require_once "Video.php";
require_once "SubArea.php";
require_once "../core/generics/State.php";
$controller = new VideoController(new VideoDao(Connection::connect()));
try {
$subarea = new SubArea(null, $_POST['subarea']);
//$state = new State($_POST['state'], null, null);
$videoLink = $controller->turnLinkToId($_POST[RequestsPatterns::$LINK]);
$video = new Video($_POST[RequestsPatterns::$TITLE], $videoLink, date("Y-m-d"), $subarea, null, $_POST['type_event'], $_POST['duration']);
$controller->save($video);
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(TRUE, "Video inserido com sucesso!")->serialize());
} catch (PDOException $err) {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(FALSE, $err->getMessage())->serialize());
} catch (Exception $err) {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(NULL, $err->getMessage())->serialize());
}
} else {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(NULL, "Todos os campos devem ser preenchidos!")->serialize());
}
} else {
$jsonResponse = new JsonResponse();
print_r($jsonResponse->response(FALSE, "Os parâmetros não foram configurados. Comunique o desenvolvedor.")->serialize());
}
示例11: JsonResponse
<?php
$jsonResponse = new JsonResponse();
if (RequestsPatterns::postParamsSetted(RequestsPatterns::$ID)) {
if (RequestsPatterns::postParamsSent(RequestsPatterns::$ID)) {
require_once 'NewsController.php';
require_once 'NewsDao.php';
$controller = new NewsController(new NewsDao(Connection::connect()));
try {
if ($controller->delete($_POST[RequestsPatterns::$ID])) {
print_r($jsonResponse->response(true, "Feed excluído com sucesso!")->serialize());
} else {
print_r($jsonResponse->response(false, "Falha ao excluir feed!")->serialize());
}
} catch (Exception $err) {
print_r($jsonResponse->response(false, $err->getMessage())->serialize());
}
} else {
print_r($jsonResponse->response(false, "O identificador da notícia não pode estar vazio!")->serialize());
}
} else {
print_r($jsonResponse->response(false, "Parâmetros não enviados")->serialize());
}
示例12: Country
<?php
require_once '../core/generics/Param.php';
require_once '../core/generics/datacenter/Country.php';
require_once '../core/generics/Controller.php';
require_once '../core/generics/GenericDao.php';
$id_country = $_POST['id'];
$country = new Country();
$country->setId($id_country);
$json = new JsonResponse();
$dao = new GenericDao(Connection::connect());
$controller = new Controller($dao);
try {
if ($controller->deleteCountry($country)) {
print_r($json->response(true, "País excluído com sucesso!")->serialize());
} else {
print_r($json->response(false, "Falha ao excluir o país.")->serialize());
}
} catch (Exception $err) {
print_r($json->response(false, $err->getMessage())->serialize());
}
示例13: JsonResponse
<?php
require_once '../core/generics/Param.php';
require_once '../core/generics/datacenter/Country.php';
require_once '../core/generics/Controller.php';
require_once '../core/generics/GenericDao.php';
$json = new JsonResponse();
$dao = new GenericDao(Connection::connect());
$controller = new Controller($dao);
$country_id = $_REQUEST['country'];
$object = new Country($_POST['name']);
$object->setId($country_id);
if (isset($_POST['reexport']) && $_POST['reexport'] == true) {
$object->setReexport();
}
if ($controller->editCountry($object)) {
print_r($json->response(true, "País editado com sucesso!")->serialize());
} else {
print_r($json->response(false, "O país não foi editado!")->serialize());
}
示例14: Country
$country = new Country($name);
$dao = new GenericDao(Connection::connect());
$controller = new Controller($dao);
$message = "País inserido com sucesso";
$message_error = "Falha na inserção do país";
try{
if($typeCountry == 'origin'){
if(isset($_POST['reexport']) && $_POST['reexport'] == true){
$country->setReexport();
}
if($controller->createNewOriginCountry($country)){
$countryToCache = $controller->getCountryByName($country,$typeCountry);
cacheCountry($countryToCache, $typeCountry);
print_r($json->response (true, $message)->serialize ());
}else
print_r($json->response (true, $message_error)->serialize ());
}else{
if($controller->createNewDestinyCountry($country)){
$countryToCache = $controller->getCountryByName($country,$typeCountry);
cacheCountry($countryToCache, $typeCountry);
print_r($json->response (true, $message)->serialize ());
}else
print_r($json->response (true, $message_error)->serialize ());
}
}catch(Exception $err){
print_r($json->response(false, $err->getMessage())->serialize());
}
}else{
print_r($json->response(false, "Os campos não podem estar vazios.")->serialize());
示例15: PublicationController
if (RequestsPatterns::postParamsSent('id', 'type')) {
require_once 'PublicationController.php';
require_once 'PublicationDao.php';
require_once 'Publication.php';
$controller = new PublicationController(new PublicationDao(Connection::connect()));
if ($_POST['type'] == 'analysis') {
require_once 'Analyse.php';
$publication = new Analyse(null);
} elseif ($_POST['type'] == 'paper') {
require_once 'Paper.php';
$publication = new Paper(null);
}
$publication->setId($_POST['id']);
try {
if ($controller->delete($publication)) {
print_r($jsonResponse->response(true, "Publicação excluída com sucesso")->serialize());
} else {
print_r($jsonResponse->response(false, "Falha ao excluir a publicação.")->serialize());
}
} catch (Exception $err) {
print_r($jsonResponse->response(false, $err->getMessage())->serialize());
}
} else {
print_r($jsonResponse->response(false, "Os parâmetros não podem estar vazios")->serialize());
}
} else {
print_r($jsonResponse->response(false, "Parâmetros não configurados")->serialize());
}
?>