Ejemplo n.º 1
0
 private function _getResponse($data, $_format)
 {
     $serializer = SerializerBuilder::create()->build();
     $jsonResponse = $serializer->serialize($data, $_format);
     $responseHandler = new ResponseHandler();
     return $responseHandler->getResponse($jsonResponse, $_format);
 }
Ejemplo n.º 2
0
 /**
  * @Route("", name="admin_search_res", options={"expose"=true})
  * @Method("POST")
  * @Template()
  */
 public function resAction(Request $request)
 {
     $finder = $this->get('product.finder');
     $finder->find($request);
     $serializer = \JMS\Serializer\SerializerBuilder::create()->build();
     $json = $serializer->serialize(array('count' => $finder->getCount(), 'page' => $finder->getPage(), 'perpage' => $finder->getPerpage(), 'data' => $finder->getData()), 'json');
     $responseHandler = new ResponseHandler();
     return $responseHandler->getResponse($json, 'json');
 }
Ejemplo n.º 3
0
 /**
  * @Route("/custom/whishlist/empty", name="api_custom_whishlist_empty", options={"expose"=true})
  * @Method("PUT")
  *
  * @ApiDoc(
  *  description="清空用戶的願望清單"
  * )
  */
 public function emptyWhishlistAction()
 {
     $custom = $this->get('session.custom')->current();
     if (!$custom) {
         return $responseHandler->getResponse(json_encode(array('status' => 2, '')), 'json');
     }
     $custom->setWhishlist(array());
     $em = $this->getDoctrine()->getManager();
     $em->persist($custom);
     $em->flush();
     $responseHandler = new ResponseHandler();
     $msg = array('status' => 1, 'msg' => 'ok', 'data' => $whishlist);
     return $responseHandler->getResponse(json_encode($msg), 'json');
 }
Ejemplo n.º 4
0
 /**
  * 取得該促銷活動已經售出之商品
  * 
  * @Route("/api/{id}/sold/{_format}", defaults={"_format"="json"}, name="promotion_api_fetch_sold", options={"expose"=true})
  * @ParamConverter("promotion", class="WoojinGoodsBundle:Promotion")
  * @Method("GET")
  */
 public function fetchSoldoutAction(Promotion $promotion, $_format)
 {
     $user = $this->get('security.token_storage')->getToken()->getUser();
     $em = $this->getDoctrine()->getManager();
     $qb = $em->createQueryBuilder();
     $qb->select('g')->from('WoojinGoodsBundle:GoodsPassport', 'g')->leftJoin('g.orders', 'o')->where($qb->expr()->eq('g.promotion', $promotion->getId()), $qb->expr()->eq('g.status', Avenue::GS_SOLDOUT), $qb->expr()->eq('o.kind', Avenue::OK_OFFICIAL));
     $products = $qb->getQuery()->getResult();
     $serializer = \JMS\Serializer\SerializerBuilder::create()->build();
     $jProducts = $serializer->serialize($products, $_format);
     $responseHandler = new ResponseHandler();
     return $responseHandler->getResponse($jProducts, $_format);
 }