当前位置: 首页>>代码示例>>PHP>>正文


PHP ParamFetcher::get方法代码示例

本文整理汇总了PHP中FOS\RestBundle\Request\ParamFetcher::get方法的典型用法代码示例。如果您正苦于以下问题:PHP ParamFetcher::get方法的具体用法?PHP ParamFetcher::get怎么用?PHP ParamFetcher::get使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FOS\RestBundle\Request\ParamFetcher的用法示例。


在下文中一共展示了ParamFetcher::get方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getRecommendedGamesAction

 /**
  * @Rest\GET("/me/recommended-games")
  * @QueryParam(name="lat", nullable=true)
  * @QueryParam(name="long", nullable=true)
  * @View(serializerEnableMaxDepthChecks=true)
  */
 public function getRecommendedGamesAction(ParamFetcher $paramFetcher)
 {
     $dm = $this->get('doctrine.odm.mongodb.document_manager');
     $user = $this->get('security.context')->getToken()->getUser();
     if ($user == "anon.") {
         throw new NotFoundHttpException();
     }
     $lat = $paramFetcher->get('lat') != null ? floatval($paramFetcher->get('lat')) : $user->getAddress()->getCoordinates()->getX();
     $long = $paramFetcher->get('long') != null ? floatval($paramFetcher->get('long')) : $user->getAddress()->getCoordinates()->getY();
     if (!isset($lat) || !isset($long)) {
         throw new NotFoundHttpException(" Debe haber alguna localización");
     }
     $nearCenters = $dm->getRepository('MIWDataAccessBundle:Center')->findClosestCenters($lat, $long);
     $geolocationService = $this->get('geolocation_service');
     $recommendedGames = array();
     $sports = $user->getSports();
     $sportsKey = is_array($sports) ? array_keys($sports) : array();
     foreach ($nearCenters as $center) {
         $games = $dm->getRepository('MIWDataAccessBundle:Game')->findAllByCenterAndSports($center, $sportsKey);
         $coordinates = $center->getAddress()->getCoordinates();
         if (count($games) > 0) {
             foreach ($games as $game) {
                 $line = array();
                 $line['distance'] = $geolocationService->getDistance($lat, $long, $coordinates->getX(), $coordinates->getY(), "K");
                 $line['game'] = $game;
                 $recommendedGames[] = $line;
             }
         }
     }
     return $this->view($recommendedGames, 200);
 }
开发者ID:carlos-mora,项目名称:pfmweb,代码行数:37,代码来源:GameController.php

示例2: getAlbumsAction

 /**
  * Get albums collection
  * Test with GET /api/v1/albums
  *
  * @ApiDoc()
  *
  * @QueryParam(name="offset", requirements="\d+", default="0", description="Offset from which to start listing")
  * @QueryParam(name="limit", requirements="\d+", default="10")
  *
  * @param ParamFetcher $paramFetcher
  *
  * @return array
  */
 public function getAlbumsAction(ParamFetcher $paramFetcher)
 {
     $limit = $paramFetcher->get('limit');
     $offset = $paramFetcher->get('offset');
     $albums = $this->get('doctrine.orm.entity_manager')->getRepository('MusicAppBundle:Album')->findBy([], null, $limit, $offset);
     return ['albums' => $albums];
 }
开发者ID:romainbriand,项目名称:api-sf2,代码行数:20,代码来源:AlbumController.php

示例3: getOffersAction

 /**
  * Récupère la liste des départements
  * GET api/offers
  * @Rest\View()
  * @Rest\QueryParam(name="sort", requirements="(created|id|name)", default="created", description="search according to date, id or name")
  * @Rest\QueryParam(name="dir", requirements="(asc|desc)", default="desc", description="sort search ascending or descending")
  *
  * @return [type] [description]
  */
 public function getOffersAction(ParamFetcher $paramFetcher)
 {
     $sortBy = $paramFetcher->get('sort');
     $sortDir = $paramFetcher->get('dir');
     $offers = $this->getDoctrine()->getManager()->getRepository('RscineOfferBundle:Offer')->findBy(array(), array($sortBy => $sortDir));
     return $offers;
 }
开发者ID:Rscine,项目名称:rscine-backend,代码行数:16,代码来源:OfferController.php

示例4: _getSelect

 protected function _getSelect(ParamFetcher $paramFetcher, Request $request)
 {
     $select = new \Kwf_Model_Select();
     $select->limit($paramFetcher->get('limit'), $paramFetcher->get('start'));
     $queryValue = trim($request->get('query'));
     if ($queryValue) {
         $exprs = array();
         if (!$this->_queryColumns) {
             throw new \Kwf_Exception("_queryColumns are required to be set");
         }
         if ($this->_querySplit) {
             $queryValue = explode(' ', $queryValue);
         } else {
             $queryValue = array($queryValue);
         }
         foreach ($queryValue as $q) {
             $e = array();
             foreach ($this->_queryColumns as $c) {
                 $e[] = new \Kwf_Model_Select_Expr_Like($c, '%' . $q . '%');
             }
             if (count($e) > 1) {
                 $exprs[] = new \Kwf_Model_Select_Expr_Or($e);
             } else {
                 $exprs[] = $e[0];
             }
         }
         if (count($exprs) > 1) {
             $select->where(new \Kwf_Model_Select_Expr_And($exprs));
         } else {
             $select->where($exprs[0]);
         }
     }
     return $select;
 }
开发者ID:koala-framework,项目名称:koala-framework,代码行数:34,代码来源:FOSRestModelController.php

示例5: getUsersAction

 /**
  * @View()
  * @QueryParam(name="offset")
  * @QueryParam(name="limit")
  * @QueryParam(name="sort", default="username")
  * @QueryParam(name="order")
  * @QueryParam(name="search")
  *
  * @return array
  */
 public function getUsersAction(ParamFetcher $paramFetcher)
 {
     $pagination = array('offset' => $paramFetcher->get('offset'), 'limit' => $paramFetcher->get('limit'));
     $sort = array('sort' => $paramFetcher->get('sort'), 'order' => $paramFetcher->get('order'));
     $search = $paramFetcher->get('search');
     return $this->get('kingdomhall.user_manager')->searchUser($pagination, $sort, $search);
 }
开发者ID:Leonhart25,项目名称:JWKingdomHall,代码行数:17,代码来源:UserController.php

示例6: getPostsAction

 /**
  * @QueryParam(name="page", requirements="\d+", default="1", description="Page of the overview")
  * @QueryParam(name="limit", requirements="\d+", default="10", description="Size of the page")
  * @QueryParam(name="sort", requirements="[a-z]+", description="Sort parameter")
  * @QueryParam(name="sort_order", requirements="(asc|desc)", allowBlank=false, default="asc", description="Sort direction")
  * @QueryParam(name="search", requirements="[a-zA-Z0-9]+", description="Search")
  * @QueryParam(name="status", requirements="(pending|publish|draft|auto-draft|future|private|inherit|trash)",  default="", nullable=true, description="Status of the posts")
  * @QueryParam(name="by_author", requirements="[a-zA-Z]+", description="By author's username", incompatibles={"search"})
  * @QueryParam(name="by_category", requirements="[a-zA-Z]+", description="By category", incompatibles={"search"})
  * @QueryParam(name="by_keywords", requirements="[a-zA-Z]+", description="By keywords", incompatibles={"search"})
  * @QueryParam(name="format", requirements="[a-z]+", default="lite", description="Format of request")
  * @Rest\View()
  */
 public function getPostsAction(ParamFetcher $paramFetcher)
 {
     $page = $paramFetcher->get("page");
     $limit = $paramFetcher->get("limit");
     $sort = $paramFetcher->get("sort");
     $sort_order = $paramFetcher->get("sort_order");
     $search = $paramFetcher->get("search");
     $status = $paramFetcher->get("status");
     $by_author = $paramFetcher->get("by_author");
     $by_category = $paramFetcher->get("by_category");
     $by_keywords = $paramFetcher->get("by_keywords");
     $format = $paramFetcher->get("format");
     $repo = $this->getDoctrine()->getManager()->getRepository('ESGISGabonPostBundle:CorporatePost');
     $posts = $repo->getPosts($format);
     $adapter = new ArrayAdapter($posts);
     $pager = new Pagerfanta($adapter);
     $pager->setMaxPerPage($limit);
     try {
         $pager->setCurrentPage($page);
     } catch (NotValidCurrentPageException $e) {
         throw new NotFoundHttpException();
     }
     $pagerfantaFactory = new PagerfantaFactory();
     $paginatedCollection = $pagerfantaFactory->createRepresentation($pager, new Route('api_get_posts', array('page' => $page, 'limit' => $limit, 'sort' => $sort, 'sort_order' => $sort_order)), new CollectionRepresentation($pager->getCurrentPageResults(), 'posts', 'posts'));
     return $paginatedCollection;
 }
开发者ID:bface007,项目名称:esgis_gabon,代码行数:39,代码来源:PostRestController.php

示例7: postPostulant

 /**
  * Ajoute un postulant à une voiture
  *
  * @ApiDoc(
  *   resource = true,
  *   description = "Ajoute un postulant à une voiture",
  *   statusCodes = {
  *     201 = "Created",
  *     404 = "Returned when the voiture is not found"
  *   }
  * )
  * @RequestParam(name="nomPostulant", nullable=true, strict=true, description="nom postulant.")
  * @RequestParam(name="telephone", nullable=true, strict=true, description="telephone postulant.")
  * @RequestParam(name="idVoiture", nullable=true,requirements="\d+", strict=true, description="id voiture postulant.")
  * @Route("api/postulants",name="nicetruc_post_postulant", options={"expose"=true})
  * @Method({"POST"})
  */
 public function postPostulant(ParamFetcher $paramFetcher)
 {
     //        try{
     $em = $this->getDoctrine()->getManager();
     $voiture = $em->getRepository('AppBundle:Voiture')->customFind($paramFetcher->get('idVoiture'));
     if (!$voiture) {
         return MessageResponse::message('Voiture introuvable', 'danger', 404);
     }
     $postulant = $em->getRepository('AppBundle:Postulant')->findBy(array('telephone' => $paramFetcher->get('telephone'), 'voiture' => $voiture));
     if ($postulant) {
         return MessageResponse::message('Ce numero a déjà postulé à cette annonce', 'warning', 200);
     }
     $postulant = new Postulant();
     $postulant->setNomPostulant($paramFetcher->get('nomPostulant'));
     $postulant->setTelephone($paramFetcher->get('telephone'));
     $postulant->setVoiture($voiture);
     $validator = $this->get('validator');
     $error = $validator->validate($postulant);
     if (count($error) > 0) {
         $message = "";
         foreach ($error as $er) {
             $message = $message . $er->getMessage() . '<br>';
         }
         return MessageResponse::message($message, 'danger', 400);
     }
     $em->persist($postulant);
     $em->flush();
     return MessageResponse::message('Enregistrement effectué avec succes', 'success', 201);
     //        }catch (BadRequestHttpException $e){
     //            dump($e);
     //            return MessageResponse::message($e->getMessage(),'danger',400);
     //        }
 }
开发者ID:2remdou,项目名称:nicetruc,代码行数:50,代码来源:PostulantController.php

示例8: postCategoryAction

 /**
  * Create a Category from the submitted data.
  *
  * @ApiDoc(
  *   resource = true,
  *   description = "Creates a new category from the submitted data.",
  *   statusCodes = {
  *     201 = "Returned when successful",
  *     400 = "Returned when the form has errors"
  *   }
  * )
  *
  * @param ParamFetcher $paramFetcher Paramfetcher
  *
  * @RequestParam(name="label", nullable=false, strict=true, description="Label.")
  * @RequestParam(name="description", nullable=true, strict=true, description="Description.")
  * @RequestParam(name="color", nullable=true, strict=true, description="Color.")
  *
  * @return View
  */
 public function postCategoryAction(ParamFetcher $paramFetcher)
 {
     $label = filter_var($paramFetcher->get('label'), FILTER_SANITIZE_STRING);
     $desc = filter_var($paramFetcher->get('description'), FILTER_SANITIZE_STRING);
     $statusCode = 201;
     if (isset($label) && $label != '') {
         //            $category = new Task();
         //            $category->setLabel($label);
         //            $category->setDescription($desc);
         //            $category->setDate(new \DateTime('now'));
         //
         //            $manager = $this->getEntityManager();
         //            $manager->persist($category);
         //            $manager->flush();
         //            $id = $category->getId();
         //            if(!isset($id)) {
         //                $statusCode = 400;
         //            }
     } else {
         $statusCode = 400;
     }
     $view = View::create();
     $view->setData('')->setStatusCode($statusCode);
     return $view;
 }
开发者ID:abvrd,项目名称:todolist,代码行数:45,代码来源:CategoryController.php

示例9: updateAddress

 /**
  * @param              $id
  * @param ParamFetcher $paramFetcher
  * @return Address
  * @throws \Exception
  */
 public function updateAddress($id, ParamFetcher $paramFetcher)
 {
     $entityManager = $this->getEntityManager();
     $address = $this->getAddress($id);
     $address->setAddressLines($paramFetcher->get('address'))->setPostcode($paramFetcher->get('postcode'))->setCountry($paramFetcher->get('country'))->setCounty($paramFetcher->get('county'))->setDistrict($paramFetcher->get('district'));
     $entityManager->flush($address);
     return $address;
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:14,代码来源:AddressRepository.php

示例10: getCatalogsAction

 /**
  *  Get Catalogs 
  *             
  * @QueryParam(name="page", requirements="\d+", default="0", description="record offset.")
  * @QueryParam(name="limit", requirements="\d+", default="100", description="number of records.")
  * @QueryParam(name="orderby", requirements="[a-z]+", allowBlank=true, default="name", description="OrderBy field")
  * @QueryParam(name="sort", requirements="(asc|desc)+", allowBlank=true, default="asc", description="Sorting order")
  *             
  * @Route("/catalogs")
  * @Method("GET")
  */
 public function getCatalogsAction(ParamFetcher $paramFetcher)
 {
     $page = $paramFetcher->get('page');
     $limit = $paramFetcher->get('limit');
     $orderby = $paramFetcher->get('orderby');
     $sort = $paramFetcher->get('sort');
     return $this->handleView($this->createView($this->get('catalog_service')->getCatalogs($page, $limit, $orderby, $sort)));
 }
开发者ID:syedomair,项目名称:SymfonyAPIProject,代码行数:19,代码来源:CatalogController.php

示例11: searchJournalUsersAction

 /**
  * @Rest\QueryParam(name="q", nullable=false, description="Query text")
  * @Rest\QueryParam(name="page_limit", nullable=true, requirements="\d+", description="Query limit", default="10")
  *
  * @param  ParamFetcher $paramFetcher
  * @param  integer $journalId
  * @return Response
  *
  * @Rest\Get("/search/journal/{journalId}/users")
  *
  * @ApiDoc(
  *   resource = true,
  *   description = "Search Journal's Users",
  *   output = "Ojs\UserBundle\Entity\User[]",
  *   statusCodes = {
  *     "200" = "Users listed successfully",
  *     "403" = "Access Denied"
  *   }
  * )
  */
 public function searchJournalUsersAction(ParamFetcher $paramFetcher, $journalId)
 {
     $em = $this->getDoctrine()->getManager();
     $defaultLimit = 20;
     $limit = $paramFetcher->get('page_limit') && $defaultLimit >= $paramFetcher->get('page_limit') ? $paramFetcher->get('page_limit') : $defaultLimit;
     $journalUsers = $em->getRepository('OjsUserBundle:User')->searchJournalUser($paramFetcher->get('q'), $journalId, $limit);
     return $journalUsers;
 }
开发者ID:hasantayyar,项目名称:ojs,代码行数:28,代码来源:SearchRestController.php

示例12: getProductsAction

 /**
  *  Get Products 
  *             
  * @QueryParam(name="page", requirements="\d+", default="0", description="record offset.")
  * @QueryParam(name="limit", requirements="\d+", default="100", description="number of records.")
  * @QueryParam(name="orderby", requirements="[a-z]+", allowBlank=true, default="name", description="OrderBy field")
  * @QueryParam(name="sort", requirements="(asc|desc)+", allowBlank=true, default="asc", description="Sorting order")
  *             
  * @Route("/products/{category_id}")
  * @Method("GET")
  */
 public function getProductsAction($category_id, ParamFetcher $paramFetcher)
 {
     $page = $paramFetcher->get('page');
     $limit = $paramFetcher->get('limit');
     $orderby = $paramFetcher->get('orderby');
     $sort = $paramFetcher->get('sort');
     return $this->handleView($this->createView($this->get('product_service')->getProductsForCategory($category_id, $page, $limit, $orderby, $sort)));
 }
开发者ID:syedomair,项目名称:SymfonyAPIProject,代码行数:19,代码来源:ProductController.php

示例13: indexAction

 /**
  * @QueryParam(name="lat", strict=true)
  * @QueryParam(name="long", strict=true)
  * @QueryParam(name="datetime", strict=true)
  */
 public function indexAction(ParamFetcher $paramFetcher)
 {
     $latitude = $paramFetcher->get('lat');
     $longtitude = $paramFetcher->get('long');
     $datetime = $paramFetcher->get('datetime');
     $city = $this->get('doctrine.orm.entity_manager')->getRepository('WeatherBundle\\Entity\\LogItem')->findNearestLogItem($latitude, $longtitude, $datetime);
     $view = View::create()->setData($city);
     return $this->container->get('fos_rest.view_handler')->handle($view);
 }
开发者ID:ufik,项目名称:weather,代码行数:14,代码来源:DefaultController.php

示例14:

 function it_should_respond_to_cget_action(ParamFetcher $paramFetcher, $repository)
 {
     $paramFetcher->get('latitude')->willReturn('foo-latitude');
     $paramFetcher->get('longitude')->willReturn('foo-longitude');
     $paramFetcher->get('from')->willReturn('foo-from');
     $paramFetcher->get('to')->willReturn('foo-to');
     $repository->findAllNear('foo-latitude', 'foo-longitude', 'foo-from', 'foo-to')->willReturn(['foo', 'bar']);
     $this->cgetAction($paramFetcher)->shouldReturn(['foo', 'bar']);
 }
开发者ID:jmleroux,项目名称:tribes,代码行数:9,代码来源:EventControllerSpec.php

示例15: createQuestionnaire

 /**
  * @param ParamFetcher $paramFetcher
  * @return Questionnaire
  * @throws \Exception
  */
 public function createQuestionnaire(ParamFetcher $paramFetcher)
 {
     $entityManager = $this->getEntityManager();
     $person = (new Person())->setFirstName($paramFetcher->get('firstname'))->setAge($paramFetcher->get('age'))->setGender($paramFetcher->get('gender'));
     $questionnaire = new Questionnaire($person);
     $entityManager->persist($questionnaire);
     $entityManager->flush($questionnaire);
     return $questionnaire;
 }
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:14,代码来源:QuestionnaireRepository.php


注:本文中的FOS\RestBundle\Request\ParamFetcher::get方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。