本文整理汇总了PHP中FOS\RestBundle\Request\ParamFetcher类的典型用法代码示例。如果您正苦于以下问题:PHP ParamFetcher类的具体用法?PHP ParamFetcher怎么用?PHP ParamFetcher使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ParamFetcher类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: getAction
/**
* @FosRest\Get("/{section}")
*
* @ApiDoc(
* description = "Get the details of a section."
* )
*
* @ParamConverter("section", class="MainBundle:Section")
*
* @FosRest\QueryParam(
* name = "token",
* nullable = false,
* description = "Mobilit token."
* )
*
* @param Section $section
* @param ParamFetcher $paramFetcher
*
* @return Response
*/
public function getAction(Section $section, ParamFetcher $paramFetcher)
{
if ($this->container->getParameter('mobilit_token') != $paramFetcher->get('token')) {
return new Response(json_encode(["message" => $this->get('translator')->trans("errors.api.android.v1.token")]), Response::HTTP_FORBIDDEN);
}
return new Response($this->get('serializer')->serialize($section, 'json', SerializationContext::create()->setGroups(array('details'))));
}
开发者ID:donatienthorez,项目名称:sf_mobilIT_backEnd,代码行数:27,代码来源:SectionController.php
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: paginate
/**
* Paginate query results using knp paginator bundle
*
* @param ParamFetcher $paramFetcher
* @param Query $query
* @param string $sortAlias
* @return Hal
*/
protected function paginate(ParamFetcher $paramFetcher, $query, $sortAlias)
{
$request = $this->getRequest();
$params = $paramFetcher->all() + $this->getPagingParams();
//alternative page start index support
if (!empty($params['pageStartIndex'])) {
$page = abs(round($params['pageStartIndex'] / $params['pageSize'])) + 1;
}
$aliasPrefix = $sortAlias . '.';
//paginator
$paginator = $this->get('knp_paginator');
//sort fields resource values to entity fields conversion
if (!empty($params['sortBy']) && substr($params['sortBy'], 0, 2) != $aliasPrefix) {
$_GET['sortBy'] = $aliasPrefix . $params['sortBy'];
//set default sortBy if none is set
} else {
//$_GET['sortBy'] = $aliasPrefix . 'id';
}
if (empty($params['sortOrder'])) {
//$_GET['sortOrder'] = 'asc';
}
$items = $paginator->paginate($query, $params['page'], $params['pageSize']);
$paginationData = $items->getPaginationData();
//root data
$rootArr = array('totalCount' => $paginationData['totalCount'], 'pageCount' => $paginationData['pageCount'], 'pageSize' => $paginationData['numItemsPerPage'], 'currentPage' => intval($paginationData['current']), 'currentPageItemCount' => $paginationData['currentItemCount']);
$entityName = $this->getEntityNameFromResourceObject($items);
$hal = new Hal($request->getUri(), $rootArr, $entityName);
//paging links
$this->addPagingLinks($hal, $paginationData);
//collection output
foreach ($items as $item) {
$hal->addResource($this->getResourceName(), new Hal($this->getResourceUrl($item, $params), $item));
}
return $hal;
}
开发者ID:sparrowDom,项目名称:pigapi,代码行数:43,代码来源:Controller.php
示例7: 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
示例8: updateSmoking
/**
* @param Smoking $smoking
* @param ParamFetcher $paramFetcher
* @return Questionnaire
* @throws \Exception
*/
public function updateSmoking(Smoking $smoking, ParamFetcher $paramFetcher)
{
$entityManager = $this->getEntityManager();
$smoking->setDoYouSmoke($paramFetcher->get('do_you_smoke'))->setCompletedDate(new \DateTime());
$entityManager->persist($smoking);
$entityManager->flush();
return $this->getQuestionnaireFromSmoking($smoking);
}
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:14,代码来源:SmokingRepository.php
示例9: 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
示例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: 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
示例12: cgetAction
/**
* Retrieve all the project resources.
*
* @ApiDoc(
* resource=true,
* description="List all project resources",
* statusCodes={
* 200="Returned when successful",
* 403="Returned when the user is not authorized",
* 404="Returned when project does not exist"
* },
* requirements={
* { "name"="project", "dataType"="string", "required"=true, "description"="Project's slug" }
* }
* )
* @Rest\QueryParam(name="project", strict=true, nullable=false)
* @Rest\View
*/
public function cgetAction(ParamFetcher $paramFetcher)
{
$project = $this->findProjectOr404($paramFetcher->get('project'));
$resources = $this->get('openl10n.repository.resource')->findByProject($project);
return (new ArrayCollection($resources))->map(function (Resource $resource) {
return new ResourceFacade($resource);
});
}
开发者ID:andreaswarnaar,项目名称:openl10n,代码行数:26,代码来源:ResourceController.php
示例13: normaliseDayDurationsToArray
/**
* @param ParamFetcher $paramFetcher
* @param string $prefix
* @return array
*/
protected function normaliseDayDurationsToArray(ParamFetcher $paramFetcher, $prefix)
{
$durationArray = array();
foreach (DayDuration::$validDays as $day) {
$durationArray[$day] = $paramFetcher->get($prefix . $day);
}
return $durationArray;
}
开发者ID:TransformCore,项目名称:HayPersistenceApi,代码行数:13,代码来源:MovingRepository.php
示例14: getAction
/**
* @FosRest\Get("/{section}")
*
* @ApiDoc(
* description = "Get the guide of a section"
* )
*
* @ParamConverter("section", class="MainBundle:Section")
*
* @FosRest\QueryParam(
* name = "token",
* nullable = false,
* description = "Mobilit token."
* )
* @param Section $section
* @param ParamFetcher $paramFetcher
*
* @return array|GuideModel
*/
public function getAction(Section $section, ParamFetcher $paramFetcher)
{
if ($this->container->getParameter('mobilit_token') != $paramFetcher->get('token')) {
return new Response(json_encode(["message" => $this->get('translator')->trans("errors.api.android.v1.token")]), Response::HTTP_FORBIDDEN);
}
$guide = $this->get('main.guide.fetcher')->getGuide($section);
$guide = $this->get('main.guide.adapter')->getModel($guide, true);
return $guide;
}
开发者ID:donatienthorez,项目名称:sf_mobilIT_backEnd,代码行数:28,代码来源:GuideController.php
示例15: listAction
/**
* @ApiDoc(
* section="Incident",
* resource=true,
* description="Returns a collection of incidents",
* output={
* "class"="array<AppBundle\Entity\Core\Incident>",
* "groups"={"list"}
* },
*
* statusCodes={
* 200="Returned when successful",
* 401="Returned when authentication fails"
* }
* )
* @QueryParam(name="page", requirements="\d+", default="1", description="Page from which to start listing incidents.")
*
* @Route("", methods={"GET"})
* @View(serializerGroups={"Default","list"})
*
* @param Request $request
* @param ParamFetcher $paramFetcher
*
* @return array
*/
public function listAction(Request $request, ParamFetcher $paramFetcher)
{
$em = $this->getDoctrine()->getManager();
$incidentRepository = $em->getRepository('AppBundle:Core\\Incident');
$page = $paramFetcher->get('page');
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate($incidentRepository->findAllIncidents(), $page, Incident::MAX_INCIDENT);
return new PagerRepresentation($pagination);
}
开发者ID:hogosha,项目名称:hogosha,代码行数:34,代码来源:IncidentController.php
示例16: listAction
/**
* @ApiDoc(
* section="Subscriber",
* resource=true,
* description="Returns a collection of subscribers",
* output={
* "class"="array<AppBundle\Entity\Core\Subscriber>",
* "groups"={"list"}
* },
*
* statusCodes={
* 200="Returned when successful",
* 401="Returned when authentication fails"
* }
* )
* @QueryParam(name="page", requirements="\d+", default="1", description="Page from which to start listing Subscribers.")
*
* @Route("", methods={"GET"})
* @View(serializerGroups={"Default","list"})
*
* @param Request $request
* @param ParamFetcher $paramFetcher
*
* @return array
*/
public function listAction(Request $request, ParamFetcher $paramFetcher)
{
$em = $this->getDoctrine()->getManager();
$subscriberRepository = $em->getRepository('AppBundle:Core\\Subscriber');
$page = $paramFetcher->get('page');
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate($subscriberRepository->findAllSubscribers(), $page, Subscriber::MAX_SUBSCRIBER);
return new PagerRepresentation($pagination);
}
开发者ID:hogosha,项目名称:hogosha,代码行数:34,代码来源:SubscriberController.php
示例17: listAction
/**
* @ApiDoc(
* section="MetricPoint",
* resource=true,
* description="Returns a collection of metrics",
* output={
* "class"="array<AppBundle\Entity\Core\MetricPoint>",
* "groups"={"list"}
* },
* statusCodes={
* 200="Returned when successful",
* 401="Returned when authentication fails"
* }
* )
* @QueryParam(name="page", requirements="\d+", default="1", description="Page from which to start metric point listing.")
*
* @Route("", methods={"GET"})
* @View(serializerGroups={"Default","list"})
*
* @param Request $request
* @param ParamFetcher $paramFetcher
*
* @return array
*/
public function listAction(Request $request, ParamFetcher $paramFetcher)
{
$em = $this->getDoctrine()->getManager();
$metricPointRepository = $em->getRepository('AppBundle:Core\\MetricPoint');
$page = $paramFetcher->get('page');
$paginator = $this->get('knp_paginator');
$pagination = $paginator->paginate($metricPointRepository->findAllMetricPoint(), $page, MetricPoint::MAX_METRIC_POINT);
return new PagerRepresentation($pagination);
}
开发者ID:hogosha,项目名称:hogosha,代码行数:33,代码来源:MetricPointController.php
示例18: 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
示例19: listAction
/**
* @FosRest\Get("")
*
* @ApiDoc(
* description = "List all the countries and their sections."
* )
*
* @FosRest\QueryParam(
* name = "token",
* nullable = false,
* description = "Mobilit token."
* )
*
* @param ParamFetcher $paramFetcher
*
* @return Response
*/
public function listAction(ParamFetcher $paramFetcher)
{
if ($this->container->getParameter('mobilit_token') != $paramFetcher->get('token')) {
return new Response(json_encode(["message" => $this->get('translator')->trans("errors.api.android.v1.token")]), Response::HTTP_FORBIDDEN);
}
$countries = $this->get('main.country.service')->getCountries(true);
$serializer = $this->get('serializer');
return new Response($serializer->serialize($countries, 'json', SerializationContext::create()->setGroups(array('listSection'))));
}
开发者ID:donatienthorez,项目名称:sf_mobilIT_backEnd,代码行数:26,代码来源:CountryController.php
示例20: getLogRequestsAction
/**
* @ApiDoc(
* section="Tools",
* description="Returns all stored log requests"
* )
*
* @Rest\QueryParam(name="page", requirements="[0-9]+", default="1", description="page")
*
* @Rest\Get("admin/system/tools/requests")
*
* @param ParamFetcher $paramFetcher
*
* @return array[items => array[], maxPages => int]
*/
public function getLogRequestsAction(ParamFetcher $paramFetcher)
{
$page = $paramFetcher->get('page');
$query = LogRequestQuery::create()->orderByDate(Criteria::DESC);
$count = ceil($query->count() / 50) ?: 0;
$paginate = $query->paginate($page, 50);
$items = $paginate->getResults()->toArray(null, null, TableMap::TYPE_CAMELNAME);
return ['items' => $items, 'maxPages' => $count];
}
开发者ID:jarves,项目名称:jarves,代码行数:23,代码来源:ToolsController.php
注:本文中的FOS\RestBundle\Request\ParamFetcher类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论