/** * Get the slug of a string in AJAX * * @param $request The request. String to slug must be sent in $request['toSlug'] * * @return $response Response */ public function getSlugAction(Request $request) { if ($request->isXmlHttpRequest()) { if ($toSlug = $request->get('toSlug')) { $slug = $this->container->get('lch.seo.tools')->getSlug($toSlug); $em = $this->getDoctrine()->getManager(); $currentSite = $request->getSession()->get('currentSite'); if (class_exists('\\LCH\\CatalogBundle\\Entity\\' . $request->get('className'))) { $entitySlug = $em->getRepository('LCHCatalogBundle:' . $request->get('className'))->findOneBySlug($slug); } elseif (class_exists('\\LCH\\ModuleBundle\\Entity\\' . $request->get('className'))) { $entitySlug = $em->getRepository('LCHModuleBundle:' . $request->get('className'))->findOneBySlug($slug); } else { throw new NotFoundHttpException("Class " . $request->get('className') . " no exists"); } // if slug already exists $response = new JsonResponse(); $id = $request->get('id') != "" ? $request->get('id') : "0"; $url = $this->container->get('lch.seo.tools')->getFrontUrlRedirection($id, $slug, $request->get('className')); if ($entitySlug) { if ($request->get('id') == $entitySlug->getId()) { // If the slug comes from the same entity $response->setData(array('slug' => $slug, 'message' => $this->container->get('translator')->trans('seo.form.url.infos') . " " . $url)); } else { $response->setData(array('slug' => $slug, 'error' => $this->container->get('translator')->trans("app.slugexists"))); } } else { $response->setData(array('slug' => $slug, 'message' => $this->container->get('translator')->trans('seo.form.url.infos') . " " . $url)); } return $response; } } }
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = new JsonResponse(['errorMessage' => $event->getException()->getMessage(), 'stackTrace' => $event->getException()->getTraceAsString()]); if ($exception instanceof HttpExceptionInterface) { $response->setStatusCode($exception->getStatusCode()); } else { if ($exception instanceof AuthenticationException) { $response->setData(['errorMessage' => 'You don\'t have permissions to do this.']); $response->setStatusCode(Response::HTTP_FORBIDDEN); } else { if ($exception instanceof InvalidFormException) { $errors = []; foreach ($exception->getForm()->getErrors(true) as $error) { if ($error->getOrigin()) { $errors[$error->getOrigin()->getName()][] = $error->getMessage(); } } $data = ['errors' => $errors, 'errorMessage' => '']; $response->setData($data); $response->setStatusCode(Response::HTTP_BAD_REQUEST); } else { $response->setStatusCode(Response::HTTP_INTERNAL_SERVER_ERROR); } } } $event->setResponse($response); }
/** * Process Ajax Form to create/update virtual product * * @param int $idProduct * @param Request $request * * @return string */ public function saveAction($idProduct, Request $request) { $response = new JsonResponse(); $legacyContext = $this->container->get('prestashop.adapter.legacy.context'); $adminProductWrapper = $this->container->get('prestashop.adapter.admin.wrapper.product'); $productAdapter = $this->container->get('prestashop.adapter.data_provider.product'); //get product $product = $productAdapter->getProduct((int) $idProduct, true); if (!$product || !$request->isXmlHttpRequest()) { return $response; } $form = $this->createForm('PrestaShopBundle\\Form\\Admin\\Product\\ProductVirtual', null, array('csrf_protection' => false)); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $res = $adminProductWrapper->updateDownloadProduct($product, $data); $res->file_download_link = $res->filename ? $legacyContext->getAdminBaseUrl() . $res->getTextLink(true) : ''; $product->is_virtual = 1; $product->save(); $response->setData($res); } else { $response->setStatusCode(400); $response->setData($this->getFormErrorsForJS($form)); } return $response; }
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = new JsonResponse(); $detail = sprintf("Message: %s\nFile: %s:%s", $exception->getMessage(), $exception->getFile(), $exception->getLine()); $data = ['type' => '#0', 'code' => 0, 'title' => 'Internal Server Error', 'status' => JsonResponse::HTTP_INTERNAL_SERVER_ERROR, 'detail' => $detail]; $response->setStatusCode(JsonResponse::HTTP_INTERNAL_SERVER_ERROR); $response->setData($data); if ($exception instanceof HttpExceptionInterface) { $response->headers->replace($exception->getHeaders()); } if ($exception instanceof HttpException) { $data = ['type' => '#' . $exception->getCode(), 'code' => $exception->getCode(), 'title' => $exception->getMessage(), 'status' => JsonResponse::HTTP_BAD_REQUEST, 'detail' => $exception->getDetails()]; $response->setStatusCode(JsonResponse::HTTP_BAD_REQUEST); $response->setData($data); } if ($exception instanceof AccessDeniedHttpException) { $event->setResponse(new Response("", 403)); } else { $event->setResponse($response); } if (!in_array($this->kernel->getEnvironment(), array('dev', 'test'))) { unset($data['detail']); } }
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = new JsonResponse(); $response->setData(['message' => $exception->getMessage()]); if ($exception instanceof HttpExceptionInterface) { $response->setStatusCode($exception->getStatusCode()); $response->headers->replace($exception->getHeaders()); } else { $response->setStatusCode(JsonResponse::HTTP_INTERNAL_SERVER_ERROR); } if ('RuntimeException' === get_class($exception)) { $response->setStatusCode($exception->getCode()); } if ($exception instanceof ArrayErrorsException) { $response->setData(['formErrors' => $exception->getErrors()]); } if ($exception instanceof AuthenticationException) { $response->setData(['message' => $exception->getMessageKey()]); $response->setStatusCode(JsonResponse::HTTP_BAD_REQUEST); } if ($exception instanceof InsufficientAuthenticationException) { $response->setData(['message' => $this->translator->trans('error.insufficient_authentication')]); $response->setStatusCode(JsonResponse::HTTP_FORBIDDEN); } $event->setResponse($response); }
/** * Process Ajax Form to add a simple category (name and parent category) * * @param Request $request * * @return string */ public function addSimpleCategoryFormAction(Request $request) { $response = new JsonResponse(); $tools = $this->container->get('prestashop.adapter.tools'); $shopContext = $this->container->get('prestashop.adapter.shop.context'); $shopList = $shopContext->getShops(false, true); $currentIdShop = $shopContext->getContextShopID(); $form = $this->createFormBuilder()->add('category', 'PrestaShopBundle\\Form\\Admin\\Category\\SimpleCategory')->getForm(); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $_POST = ['submitAddcategory' => 1, 'name_1' => $data['category']['name'], 'id_parent' => $data['category']['id_parent'], 'link_rewrite_1' => $tools->link_rewrite($data['category']['name']), 'active' => 1, 'checkBoxShopAsso_category' => $currentIdShop ? [$currentIdShop => $currentIdShop] : $shopList]; $adminCategoryController = $this->container->get('prestashop.adapter.admin.controller.category')->getInstance(); if ($category = $adminCategoryController->processAdd()) { $response->setData(['category' => $category]); } if ($request->query->has('id_product')) { $productAdapter = $this->get('prestashop.adapter.data_provider.product'); $product = $productAdapter->getProduct($request->query->get('id_product')); $product->addToCategories($category->id); $product->save(); } } else { $response->setStatusCode(400); $response->setData($this->getFormErrorsForJS($form)); } return $response; }
/** * Controller to return the access token when a refresh token is provided. * * @todo: Get some flood protection for this, since the request is uncacheable * because of the expire counter. Also, there has to be some other better way * to render JSON. Investigate that too! */ public function refresh() { $account = $this->currentUser()->getAccount(); // If the account is not a token account, then bail. if (!$account instanceof TokenAuthUserInterface) { // TODO: Set the error headers appropriately. return NULL; } $refresh_token = $account->getToken(); if (!$refresh_token || !$refresh_token->isRefreshToken()) { // TODO: Set the error headers appropriately. return NULL; } // Find / generate the access token for this refresh token. $access_token = $refresh_token->get('access_token_id')->entity; if (!$access_token || $access_token->get('expire')->value < REQUEST_TIME) { // If there is no token to be found, refresh it by generating a new one. $values = ['expire' => $refresh_token::defaultExpiration(), 'user_id' => $refresh_token->get('user_id')->target_id, 'auth_user_id' => $refresh_token->get('auth_user_id')->target_id, 'resource' => $access_token ? $access_token->get('resource')->target_id : 'global', 'created' => REQUEST_TIME, 'changed' => REQUEST_TIME]; /* @var AccessTokenInterface $access_token */ $access_token = $this->entityManager()->getStorage('access_token')->create($values); // This refresh token is no longer needed. $refresh_token->delete(); // Saving this token will generate a refresh token for that one. $access_token->save(); } $this->response->setData($this->normalize($access_token)); return $this->response; }
/** * Manage form add product attachment * * @param int $idProduct * @param Request $request * * @return string */ public function addAction($idProduct, Request $request) { $response = new JsonResponse(); $legacyContext = $this->container->get('prestashop.adapter.legacy.context'); $adminProductWrapper = $this->container->get('prestashop.adapter.admin.wrapper.product'); $productAdapter = $this->container->get('prestashop.adapter.data_provider.product'); //get product $product = $productAdapter->getProduct((int) $idProduct); if (!$product || !$request->isXmlHttpRequest()) { return $response; } $form = $this->createForm('PrestaShopBundle\\Form\\Admin\\Product\\ProductAttachement', null, array('csrf_protection' => false)); $form->handleRequest($request); if ($form->isValid()) { $data = $form->getData(); $res = $adminProductWrapper->processAddAttachment($product, $data, $legacyContext->getLanguages()); if ($res) { $res->real_name = $data['name']; $response->setData($res); } } else { $response->setStatusCode(400); $response->setData($this->getFormErrorsForJS($form)); } return $response; }
/** * Request reset user password: submit form and send email */ public function sendEmailAction(Request $request) { $username = $request->get('username'); $template = $request->get('template'); $routereset = $request->get('routereset'); $type = $request->get('type'); if (empty($template)) { $template = str_replace('::', ':', $this->container->getParameter('sfynx.auth.theme.login')) . 'Resetting:request.html.twig'; } $user = $this->container->get('doctrine')->getManager()->getRepository('SfynxAuthBundle:User')->findOneBy(array('username' => $username)); if ($request->isXmlHttpRequest()) { $response = new JsonResponse(); if (null === $user) { return $response->setData(json_encode(array('text' => 'Identifiant inconnu', 'error' => true, 'type' => 'unknown'))); } else { if ($user->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl')) && $type == 'send') { return $response->setData(json_encode(array('text' => 'Vous devez au préalable activer votre compte en cliquant sur le mail de Confirmation d\'inscription reçu', 'error' => true, 'type' => '24h'))); } else { $tokenGenerator = $this->container->get('fos_user.util.token_generator'); $user->setConfirmationToken($tokenGenerator->generateToken()); $em = $this->container->get('doctrine')->getManager(); $em->persist($user); $em->flush(); $this->container->get('session')->set(PiMailerManager::SESSION_EMAIL, $this->container->get('sfynx.auth.mailer')->getObfuscatedEmail($user)); $this->container->get('sfynx.auth.mailer')->sendResettingEmailMessage($user, $routereset); $user->setPasswordRequestedAt(new \DateTime()); $this->container->get('fos_user.user_manager')->updateUser($user); return $response->setData(json_encode(array('text' => 'Un email vous a été envoyé pour créer un nouveau mot de passe sur le site', 'error' => false))); } } } else { if (null === $user) { return $this->container->get('templating')->renderResponse($template, array('invalid_username' => $username)); } if ($user->isPasswordRequestNonExpired($this->container->getParameter('fos_user.resetting.token_ttl'))) { return $this->container->get('templating')->renderResponse(str_replace('::', ':', $this->container->getParameter('sfynx.auth.theme.login')) . 'Resetting:passwordAlreadyRequested.html.twig'); } $tokenGenerator = $this->container->get('fos_user.util.token_generator'); $user->setConfirmationToken($tokenGenerator->generateToken()); $em = $this->container->get('doctrine')->getManager(); $em->persist($user); $em->flush(); // $this->container->get('session')->set(PiMailerManager::SESSION_EMAIL, $this->container->get('sfynx.auth.mailer')->getObfuscatedEmail($user)); $this->container->get('sfynx.auth.mailer')->sendResettingEmailMessage($user, $routereset); $user->setPasswordRequestedAt(new \DateTime()); $this->container->get('fos_user.user_manager')->updateUser($user); try { return $this->container->get('templating')->renderResponse($template, array('success' => true)); } catch (\Exception $e) { $response = new RedirectResponse($this->container->get('router')->generate('fos_user_resetting_check_email')); } return $response->getContent(); } }
public function expiredAction($id) { $utilis = $this->getDoctrine()->getRepository('GenericBundle:User')->find($id); $reponse = new JsonResponse(); if ($utilis->isExpired()) { $utilis->setExpired(false); $reponse->setData(array('succes' => '0')); } else { $utilis->setExpired(true); $reponse->setData(array('succes' => '1')); } $this->getDoctrine()->getEntityManager()->flush(); return $reponse; }
public function onKernelException(GetResponseForExceptionEvent $event) { $exception = $event->getException(); $response = new JsonResponse(); if ($exception instanceof HttpExceptionInterface) { $response->setStatusCode($exception->getStatusCode()); $response->headers->replace($exception->getHeaders()); $response->setData(array('message' => $exception->getMessage())); } else { $response->setData(array('message' => 'An internal server error occurred. Sorry for the inconvenience.')); $response->setStatusCode(JsonResponse::HTTP_INTERNAL_SERVER_ERROR); } $event->setResponse($response); }
/** * @param \Dafiti\Silex\Response $controllerResponse * * @return HttpFoundation\Response */ protected function transform(\Dafiti\Silex\Response $controllerResponse) { $response = new HttpFoundation\JsonResponse(); $response->headers->add(['Content-Type' => self::CONTENT_TYPE]); $response->setStatusCode($controllerResponse->getStatusCode()); if ($this->hasError()) { $content = ['message' => $controllerResponse->getErrorMessage()]; $response->setData($content); return $response; } $response->setStatusCode($controllerResponse->getStatusCode()); $content = $this->getContent($controllerResponse); $response->setData($content); return $response; }
function edit(City $city) { $response = new JsonResponse(); $id = $city->getId(); $object = $this->repository->getOneById($id); if ($object == null) { $response->setData(array('flag' => false, 'info' => "Error! No object for given id")); return $response; } $object->setName($city->getName()); $object->setPtt($city->getPtt()); $this->repository->flush(); $response->setData(array('flag' => true, 'info' => "ok")); return $response; }
/** * @Route("/check-connection", name="check-db-connection") */ public function asyncDBCheck(Request $request) { if ($request->isXMLHttpRequest()) { $databaseArgs = array('name' => $request->request->get('name')); $connectionStatus = $this->checkConnection($databaseArgs); $response = new JsonResponse(); if ($connectionStatus) { $response->setData(array('action' => 'db_check', 'status' => 'success')); } else { $response->setData(array('action' => 'db_check', 'status' => 'failure')); } return $response; } return new Response('This is not ajax!', 400); }
/** * Deletes a Comment entity. * * @Route("/comment/{id}", name="front_comment_delete") * @Method("DELETE") * @param Request $request * @param Comment $comment * @return JsonResponse */ public function deleteCommentAction(Request $request, Comment $comment) { $response = new JsonResponse(); // check for "edit" access: calls all voters $perm = $this->isGranted('edit', $comment); if ($perm) { $em = $this->getDoctrine()->getManager(); $em->remove($comment); $em->flush(); $response->setData(['success' => true]); } else { $response->setData(['success' => false]); } return $response; }
function edit(Club $club) { $response = new JsonResponse(); $object = $this->repository->getOneById($club->getId()); if ($object == null) { $response->setData(array('flag' => false, 'info' => "Error! No object for given id")); return $response; } $city = $this->cityManager->getOneById($club->getCity()->getId()); $object->setCity($city); $object->setName($club->getName()); $this->repository->flush(); $response->setData(array('flag' => true, 'info' => "ok")); return $response; }
public function acceptCookiesAction($id) { $this->setCookie($id); $response = new JsonResponse(); $response->setData(['message' => 'Cookiewall block added to session']); return $response; }
public function dbAction(Db $db, JsonResponse $response) { $conn = $db->getConnection(); $sql = "SELECT * FROM test"; $stmt = $conn->query($sql); return $response->setData($stmt->fetchAll()); }
public function menuAction() { $em = $this->getDoctrine()->getManager(); $allRegionsCities = $em->getRepository('KvartiriBundle:Regions')->findAll(); if ($allRegionsCities) { $data = array(); $cpt = 0; foreach ($allRegionsCities as $regionCities) { $cpt1 = 0; $data[$cpt]['label'] = $regionCities->getName(); $data[$cpt]['id'] = $regionCities->getId(); $child = array(); foreach ($regionCities->getCities() as $city) { $child[$cpt1]['label'] = $city->getName(); $child[$cpt1]['id'] = $city->getId(); $cpt1++; } $data[$cpt]['children'] = $child; $cpt++; } } else { $data = null; } $response = new JsonResponse(); return $response->setData(array('data' => $data)); }
public function RefreshNotificationAction($id, Request $request) { if ($request->isXmlHttpRequest()) { // si on appele depuis une requette ajax $em = $this->getDoctrine()->getManager(); $Allnotifs = $em->getRepository('OCNotificationBundle:Notification')->findByPourAgent($id); if ($Allnotifs) { $notifs = array(); foreach ($Allnotifs as $notif) { $interval = $notif->getDateCreation()->diff(new \DateTime('now')); if ($interval->format('%a') == "0") { $date = "aujourd'hui"; } elseif ($interval->format('%a') == "1") { $date = "hier"; } else { $date = $interval->format('%a jours'); } if ($notif->getEventAssocie() !== null) { $nom_agent = $notif->getEventAssocie()->getAgent()->getNomCanonique(); } else { $nom_agent = $notif->getHSFAssocie()->getAgent()->getNomCanonique(); } $notifs[$notif->getId()] = array($notif->getId(), $nom_agent, $notif->getTitle(), $notif->getVisionee(), $date); } } else { $notif = null; } //var_dump($notifs); //die(); $response = new JsonResponse(); return $response->setData(array('notifs' => $notifs)); } else { throw new Exception("Vous n'etes pas censés être ici ! Cassez vous !"); } }
/** * Preparing a JsonResponse * * @param array $data * @param integer $statusCode */ protected function prepareJsonResponse($data = array(), $statusCode = Response::HTTP_OK) { $response = new JsonResponse(); $response->setData($data); $response->setStatusCode($statusCode); return $response; }
/** * @inheritdoc */ public function start(Request $request, AuthenticationException $authException = null) { $response = new JsonResponse(); $response->setStatusCode(401); $response->setData(['ok' => false, 'error' => 'Accessing this resource requires authorization']); return $response; }
/** * Search for the specified entity by its property * * @Route("/choices/{class}/{property}", name="BluemesaCoreBundle_ajax_choices") * * @param Request $request * @param string $class Entity class to search for * @param string $property Property to lookup in search * @return Response * @throws InvalidArgumentException */ public function choicesAction(Request $request, $class, $property) { $query = $request->query->get('query'); $repository = $this->getDoctrine()->getRepository($class); if (!$repository instanceof EntityRepository) { throw new InvalidArgumentException(); } $qb = $repository->createQueryBuilder('b'); $terms = explode(" ", $query); foreach ($terms as $term) { $qb = $qb->andWhere("b." . $property . " like '%" . $term . "%'"); } $found = $qb->getQuery()->getResult(); $propertyPath = null !== $property ? new PropertyPath($property) : null; $propertyAccessor = PropertyAccess::createPropertyAccessor(); $options = array(); foreach ($found as $entity) { if (null !== $propertyPath) { $options[] = (string) $propertyAccessor->getValue($entity, $propertyPath); } else { $options[] = (string) $entity; } } $response = new JsonResponse(); $response->setData($options); return $response; }
/** * @Secure(roles="ROLE_USER, ROLE_ADMINISTRATOR") */ public function updateAction(Request $request) { $params = []; $requestBody = $this->get("request")->getContent(); if (!empty($requestBody)) { $params = json_decode($requestBody, true); $em = $this->getDoctrine()->getManager(); $user = $this->get('security.context')->getToken()->getUser(); //$slices = explode(':', $params['grid']); //array_pop($slices); $grid = $params['grid']; $fields = implode('|', $params['fields']); //$layout = $this->get('app_core.grid_layout_repository') $layout = $em->getRepository('CoreBundle:GridLayout')->findUserLayout($grid, $user->getId()); if (is_null($layout)) { $layout = new GridLayout(); } $layout->setUser($user); $layout->setGrid($grid); $layout->setLayout($fields); $em->persist($layout); $em->flush(); } $response = new JsonResponse(); $responseBody = []; $response->setData($responseBody); return $response; }
/** * @Route("/evento/get", name="get_event") */ public function retrieveEvent() { $request = Request::createFromGlobals(); $from = $request->query->get('from'); $to = $request->query->get('to'); if ($from && $to) { $em = $this->getDoctrine()->getManager(); $q = "SELECT e FROM AppBundle\\Entity\\Evento e WHERE (e.fechainicio>=:from AND e.fechainicio<=:to) OR (e.fechafin>=:from AND e.fechafin<=:to)"; $query = $em->createQuery($q); $query->setParameter('from', date("Y/m/d H:i:s", $from / 1000)); $query->setParameter('to', date("Y/m/d H:i:s", $to / 1000)); $events = $query->getResult(); $jevents = array(); foreach ($events as $ev) { $jevents[] = array("id" => $ev->getIdEvento(), "title" => $ev->getDescripcion(), "url" => "http://example.com", "class" => "event-important", "start" => 1000 * strtotime($ev->getFechainicio()->format('Y-m-d H:i:s')), "end" => 1000 * strtotime($ev->getFechafin()->format('Y-m-d H:i:s'))); } $result = array("success" => 1, "result" => $jevents); $response = new JsonResponse(); $response->setData($result); return $response; } else { $result = array("success" => 1, "result" => array()); $response = new JsonResponse(); $response->setData($result); return $response; } }
public function menuappAction() { $menuItems = $this->container->get('app_core.menu')->getMenu(); $response = new JsonResponse(); $json = $this->createResponse($menuItems); return $response->setData($json); }
public function datePromotionsAction($hotelId, $dateStart) { $em = $this->getDoctrine()->getManager(); $hotel = $em->getRepository('KvartiriBundle:Hotels')->find($hotelId); $test = ''; if ($hotel) { $date = new \DateTime($dateStart); $now = new \DateTime(); $diff = date_diff($date, $now); $daysDiff = $diff->y * 365.25 + $diff->m * 30 + $diff->d + $diff->h / 24 + $diff->i / 60; $checkValue = 0; $getPromotion = ""; foreach ($hotel->getPromotionEarlyBooking() as $promotion) { $numbreDaysPromotionDB = $promotion->getDays(); if ($numbreDaysPromotionDB && $daysDiff >= $numbreDaysPromotionDB && $checkValue < $numbreDaysPromotionDB) { $checkValue = $numbreDaysPromotionDB; $getPromotion = $promotion->getDiscount() * 100; $getPromotion = "You have " . $getPromotion . "% discount"; } else { $getPromotion = "we can not offer you a promotion"; } } // $promotion = $date->diff($now)->format("%d days, %h hours and %i minuts"); } else { $test = null; } // return $this->render('UsersBundle:ClientsRequests:promotions.html.twig', array('getPromotion' => $getPromotion)); $response = new JsonResponse(); return $response->setData(array('getPromotion' => $getPromotion)); }
public function onKernelView(GetResponseForControllerResultEvent $event) { if (!$event->isMasterRequest()) { return; } $request = $event->getRequest(); if ('json' !== $request->getRequestFormat()) { return; } $result = $event->getControllerResult(); if (null === $result) { $event->setResponse(new JsonResponse(null, 204)); return; } if ($result instanceof Response) { return; } $response = new JsonResponse(); if ($request->isMethod('POST')) { $response->setStatusCode(201); } if (!is_scalar($result)) { $result = $this->getSerializer()->normalize($result, null, ['groups' => $this->options['serialization_default_groups']]); } $response->setData($result); $event->setResponse($response); }
public function jsonAction() { $repository = $this->getDoctrine()->getRepository('AppTruckingBundle:Trucks'); $result = $repository->getTrucksToJson(); $response = new JsonResponse(); return $response->setData($result); }
public function getJSONError($error) { $response = new JsonResponse(); $data = array('success' => false, 'error' => $error); $response->setData($data); return $response; }